-# create .my.cnf
-# only if dbusername and dbpassword specified.
-# we create a tmp file because we don't want to
-# specify the password on the command line.
-
-defaultsfile=""
-
-if [ "$dbusername" != "" -a "$dbpassword" != "" ]
-then
- if [ $usevserver = yes ]
- then
- vhome=`$VSERVER $vsname exec getent passwd "root" | @AWK@ -F: '{print $6}'`
- home="$vroot$vhome"
- else
- home=`getent passwd "root" | @AWK@ -F: '{print $6}'`
- fi
-
- [ -d $home ] || fatal "Can't find root's home directory ($home)."
-
- mycnf="$home/.my.cnf"
-
- if [ -f $mycnf ]
- then
- # rename temporarily
- tmpcnf="$home/my.cnf.disable"
- debug "mv $mycnf $tmpcnf"
- mv $mycnf $tmpcnf
- fi
-
- oldmask=`umask`
- umask 077
- cat > $mycnf <<EOF
-# auto generated backupninja mysql conf
-[mysql]
-host=$dbhost
-user=$dbusername
-password="$dbpassword"
-
-[mysqldump]
-host=$dbhost
-user=$dbusername
-password="$dbpassword"
-
-[mysqlhotcopy]
-host=$dbhost
-user=$dbusername
-password="$dbpassword"
+ # create backup dirs, $vroot will be empty if no vsname was specified
+ # and we will instead proceed to operate on the host
+ [ -d $vroot$interpolated ] || mkdir -p $vroot$interpolated
+ [ -d $vroot$interpolated ] || fatal "Backup directory '$vroot$backupdir'"
+
+ hotdir="$interpolated/hotcopy"
+ dumpdir="$interpolated/sqldump"
+
+ [ "$sqldump" == "no" -o -d $vroot$dumpdir ] || mkdir -p $vroot$dumpdir
+ [ "$hotcopy" == "no" -o -d $vroot$hotdir ] || mkdir -p $vroot$hotdir
+
+ #######################################################################
+ ## AUTHENTICATION
+
+ #
+ # one of three authentication methods:
+ # 1. setting the user, so that /home/user/.my.cnf is used.
+ # 2. specifying the user and password in the handler config,
+ # which generates a temporary .my.cnf in /root/.my.cnf
+ # 3. specify the config file with --defaults-extra-file
+ # (this option DOESN'T WORK WITH MYSQLHOTCOPY)
+ #
+
+ # create .my.cnf
+ # only if dbusername and dbpassword specified.
+ # we create a tmp file because we don't want to
+ # specify the password on the command line.
+
+ defaultsfile=""
+
+ if [ "$dbusername" != "" -a "$dbpassword" != "" ]
+ then
+ vhome=`$vexec getent passwd "root" | @AWK@ -F: '{print $6}'`
+ home=$vroot$vhome
+
+ [ -d $home ] || fatal "Can't find root's home directory ($home)."
+
+ mycnf="$home/.my.cnf"
+
+ if [ -f $mycnf ]
+ then
+ # rename temporarily
+ tmpcnf="$home/my.cnf.disable"
+ debug "mv $mycnf $tmpcnf"
+ mv $mycnf $tmpcnf
+ fi
+
+ oldmask=`umask`
+ umask 077
+ cat > $mycnf <<EOF
+ # auto generated backupninja mysql conf
+ [mysql]
+ host=$dbhost
+ user=$dbusername
+ password="$dbpassword"
+
+ [mysqldump]
+ host=$dbhost
+ user=$dbusername
+ password="$dbpassword"
+
+ [mysqlhotcopy]
+ host=$dbhost
+ user=$dbusername
+ password="$dbpassword"