- # If requested, dump only the table structure for this database
- if echo "$nodata" | grep -E '(^|[[:space:]])'"$db\." >/dev/null
- then
- # Get the structure of the tables, without data
- DUMP_STRUCT="$DUMP_BASE --no-data $db"
- for qualified_table in $nodata
- do
- table=$( expr match "$qualified_table" "$db\.\([^\w]*\)" )
- DUMP_STRUCT="$DUMP_STRUCT $table"
- done
- DUMP="( $DUMP; $DUMP_STRUCT )"
- fi
- if [ $usevserver = yes ]
- then
- # Test to make sure mysqld is running, if it is not sqldump will not work
- $VSERVER $vsname exec su $user -c "$MYSQLADMIN $defaultsfile ping"
- if [ $? -ne 0 ]; then
- fatal "Either you have an authentication problem, or mysqld doesn't appear to be running!"
- fi
- if [ "$compress" == "yes" ]; then
- execstr="$VSERVER $vsname exec $DUMP | $GZIP > $vroot$dumpdir/${db}.sql.gz"
- else
- execstr="$VSERVER $vsname exec $DUMP -r $vroot$dumpdir/${db}.sql"
- fi
- else
- # Test to make sure mysqld is running, if it is not sqldump will not work
- su $user -c "$MYSQLADMIN $defaultsfile ping"
- if [ $? -ne 0 ]; then
- fatal "Either you have an authentication problem, or mysqld doesn't appear to be running!"
- fi
- if [ "$compress" == "yes" ]; then
- execstr="$DUMP | $GZIP > $dumpdir/${db}.sql.gz"
- else
- execstr="$DUMP -r $dumpdir/${db}.sql"
- fi
- fi
- 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 dump of mysql database $db"
- else
- warning $output
- warning "Failed to dump mysql databases $db"
- fi
- fi
- done
+ # If requested, dump only the table structure for this database
+ if echo "$nodata" | grep -E '(^|[[:space:]])'"$db\." >/dev/null
+ then
+ # Get the structure of the tables, without data
+ DUMP_STRUCT="$DUMP_BASE --no-data $db"
+ for qualified_table in $nodata
+ do
+ table=$( expr match "$qualified_table" "$db\.\([^\w]*\)" )
+ DUMP_STRUCT="$DUMP_STRUCT $table"
+ done
+ DUMP="( $DUMP; $DUMP_STRUCT )"
+ fi
+ if [ $usevserver = yes ]
+ then
+ # Test to make sure mysqld is running, if it is not sqldump will not work
+ $VSERVER $vsname exec su $user -c "$MYSQLADMIN $defaultsfile ping 2>&1 >/dev/null"
+ if [ $? -ne 0 ]; then
+ fatal "mysqld doesn't appear to be running!"
+ fi
+ if [ "$compress" == "yes" ]; then
+ execstr="$VSERVER $vsname exec $DUMP | $GZIP --rsyncable > '$vroot$dumpdir/${db}.sql.gz'"
+ else
+ execstr="$VSERVER $vsname exec $DUMP -r '$vroot$dumpdir/${db}.sql'"
+ fi
+ else
+ # Test to make sure mysqld is running, if it is not sqldump will not work
+ su $user -c "$MYSQLADMIN $defaultsfile ping 2>&1 >/dev/null"
+ if [ $? -ne 0 ]; then
+ fatal "mysqld doesn't appear to be running!"
+ fi
+ if [ "$compress" == "yes" ]; then
+ execstr="$DUMP | $GZIP --rsyncable > '$dumpdir/${db}.sql.gz'"
+ else
+ execstr="$DUMP -r '$dumpdir/${db}.sql'"
+ fi
+ fi
+ debug "su $user -c \"$execstr\""
+ if [ ! $test ]
+ then
+ output=`su $user -c "set -o pipefail ; $execstr" 2>&1`
+ code=$?
+ if [ "$code" == "0" ]
+ then
+ debug $output
+ info "Successfully finished dump of mysql database $db"
+ else
+ warning $output
+ warning "Failed to dump mysql databases $db"
+ fi
+ fi
+ done