-##########################################################################
-## SQL DUMP
-
-if [ "$sqldump" == "yes" ]
-then
- info "Initializing SQL dump method"
- if [ "$databases" == "all" ]
- then
- if [ $usevserver = yes ]
- then
- debug "$VSERVER $vsname exec su $user -c \"$MYSQL $defaultsfile -N -B -e 'show databases'\" | sed 's/|//g;/\+----/d'"
- databases=`$VSERVER $vsname exec su $user -c "$MYSQL $defaultsfile -N -B -e 'show databases'" | sed 's/|//g;/\+----/d'`
- if [ $? -ne 0 ]
- then
- fatal "Authentication problem, maybe user/password is wrong or mysqld is not running?"
- fi
- else
- databases=$(su $user -c "$MYSQL $defaultsfile -N -B -e 'show databases'" | sed 's/|//g;/\+----/d')
- if [ $? -ne 0 ]
- then
- fatal "Authentication problem, maybe user/password is wrong or mysqld is not running?"
- fi
- fi
- fi
-
- for db in $databases
- do
- DUMP_BASE="$MYSQLDUMP $defaultsfile $sqldumpoptions"
-
- # Dumping structure and data
- DUMP="$DUMP_BASE $ignore $db"
-
- # If requested, dump only the table structure for this database
- if echo "$nodata" | grep -E '(^|[[:space:]])'"$db\." >/dev/null
+ if [ "$hotcopy" == "yes" ]
+ then
+ if starts_with "$hotdir" "$vroot"; then
+ info "Initializing hotcopy method"
+ vhotdir=`strip_prefix "$hotdir" "$vroot"`
+ if [ "$databases" == "all" ]
+ then
+ info "dbhost: $dbhost"
+ execstr="$vexec $MYSQLHOTCOPY -h $dbhost --quiet --allowold --regexp /.\*/./.\*/ $vhotdir"
+
+ debug "su $user -c \"$execstr\""
+ if [ ! $test ]
+ then
+ output=`su $user -c "$execstr" 2>&1`
+ code=$?
+ if [ "$code" == "0" ]
+ then
+ debug $output
+ info "Successfully finished hotcopy of all mysql databases"
+ else
+ warning $output
+ warning "Failed to hotcopy all mysql databases"
+ fi
+ fi
+ else
+ for db in $databases
+ do
+ execstr="$vexec $MYSQLHOTCOPY -h $dbhost --allowold $db $vhotdir"
+
+ debug 'su $user -c \"$execstr\"'
+ if [ ! $test ]
+ then
+ output=`su $user -c "$execstr" 2>&1`
+ code=$?
+ if [ "$code" == "0" ]
+ then
+ debug $output
+ info "Successfully finished hotcopy of mysql database $db"
+ else
+ warning $output
+ warning "Failed to hotcopy mysql database $db"
+ fi
+ fi
+ done
+ fi
+ else
+ error "hotcopy method can only be used when the backupdir ($hotdir) is within the vserver ($vroot)"
+ fi
+ fi
+
+ ##########################################################################
+ ## SQL DUMP
+
+ if [ "$sqldump" == "yes" ]
+ then
+ info "Initializing SQL dump method"
+ if [ "$databases" == "all" ]
+ then
+ debug "$vexec su $user -c \"$MYSQL $defaultsfile -N -B -e 'show databases'\" | sed 's/|//g;/\+----/d'"
+ # -N removes the column title and -B should remove the ASCII table borders, but doesn't always so we use sed to make sure.
+ databases=`$vexec su $user -c "$MYSQL $defaultsfile -N -B -e 'show databases'" | sed 's/|//g;/\+----/d'`
+ if [ $? -ne 0 ]