Here is what I did to mysql.bk and even though it is kinda clunkly it works fine for me (FC1). We are welcome to use it, modify it or whatever.
If you improve it, please let me know.
mysql.bk:
DIR_PREFIX="mysql"
if [ "$MYSQL_BK" = "1" ]; then
echo "Performing MySQL backup "
echo "Performing MySQL backup " >> $QLOG
# shut off mysqld in the dataskq
# First copy the file to get the perms and ownership right
echo -n " Marking MySQL as off: "
echo -n " Marking MySQL as off: " >> $QLOG
cp -af /usr/local/directadmin/data/admin/services.status /usr/local/directadmin/data/admin/services.status.tmp
# Replace the bits that need replacing into the copy
sed "s/mysqld=ON/mysqld=OFF/" /usr/local/directadmin/data/admin/services.status > /usr/local/directadmin/data/admin/services.status.tmp
# Now copy it back to the right location preserving the ownerships and perms
cp -af /usr/local/directadmin/data/admin/services.status.tmp /usr/local/directadmin/data/admin/services.status
rm -f /usr/local/directadmin/data/admin/services.status.tmp
echo "Completed" >> $QLOG
echo_completed
echo -n " Stage 1 MySQL backup:"
echo -n " Stage 1 MySQL backup:" >> $QLOG
$MYSQL_INIT stop >> /dev/null 2>&1
if [ -f "$MYSQL_PID" ]; then
$MYSQL_INIT stop >> /dev/null 2>&1
sleep 4
if [ -f "$MYSQL_PID" ]; then
echo_fail
echo "MySQL could not be shutdown, aborting..."
echo "MySQL could not be shutdown, aborting..." >> $QLOG
postbk
exit 1
fi
fi
SIM_CRON=`cat /etc/crontab | grep sim`
if [ -f "/usr/local/sim/sim" ] && [ ! "$SIM_CRON" = "" ]; then
chmod 000 /usr/local/sim/sim
SIM_OFF="1"
fi
arc $MYSQL_PATH full-mysql mysql
echo -n " Stage 2 MySQL backup:"
echo -n " Stage 2 MySQL backup:" >> $QLOG
if [ "$MYSQL_RVAL" = "" ] && [ ! -f "$MYSQL_PID" ]; then
$NICE -n $PRI $MYSQL_MYICHK --silent --force --fast --update-state -O key_buffer=64M \
-O sort_buffer=64M -O read_buffer=1M -O write_buffer=1M $MYSQL_PATH/*/*.MYI
fi
echo " Completed" >> $QLOG
echo_completed
# Now mark mysqld as ON again in DA
# First copy the file to get the perms and ownership right
echo -n " Marking MySQL as on : "
echo -n " Marking MySQL as on : " >> $QLOG
cp -af /usr/local/directadmin/data/admin/services.status /usr/local/directadmin/data/admin/services.status.tmp
# Replace the bits that need replacing into the copy
sed "s/mysqld=OFF/mysqld=ON/" /usr/local/directadmin/data/admin/services.status > /usr/local/directadmin/data/admin/services.status.tmp2
# Now copy it back to the right location preserving the ownerships and perms
cp -af /usr/local/directadmin/data/admin/services.status.tmp /usr/local/directadmin/data/admin/services.status
/usr/local/directadmin/data/admin/services.status.tmp
echo "Completed" >> $QLOG
echo_completed
echo " Stage 3 MySQL backup:"
echo " Stage 3 MySQL backup:" >> $QLOG
$MYSQL_INIT start >> /dev/null 2>&1
sleep 4
MYSQL_RVAL=`ps -auxww | grep mysqld | grep -v grep`
if [ "$MYSQL_RVAL" = "" ] && [ ! -f "$MYSQL_PID" ]; then
echo_fail
echo "MySQL could not be started, aborting..."
echo "MySQL could not be started, aborting..." >> $QLOG
postbk
exit 1
elif [ "$MYSQL_RVAL" = "" ]; then
echo_fail
echo "MySQL could not be started, aborting..."
echo "MySQL could not be started, aborting..." >> $QLOG
postbk
exit 1
fi
if [ "$SIM_OFF" = "1" ]; then
chmod 755 /usr/local/sim/sim >> /dev/null 2>&1
SIM_OFF="0"
fi
sleep 1
MYSQL_USRDB=`ls $MYSQL_PATH`
for i in $MYSQL_USRDB; do
if [ -d "$MYSQL_PATH/$i" ] && [ "$DIR_PREFIX" = "" ]; then
echo -n " Dumping database $i: "
echo -n " Dumping database $i: " >> $QLOG
$NICE -n $PRI $MYSQL_DUMP -l -u$MYSQL_ROOTUN -p$MYSQL_ROOTPW $i > $BACKUP_PATH/$DATE/$i.sql
arc $BACKUP_PATH/$DATE/$i.sql $i.sql
rm -f $BACKUP_PATH/$DATE/$i.sql
elif [ -d "$MYSQL_PATH/$i" ] && [ ! "$DIR_PREFIX" = "" ]; then
echo -n " Dumping database $i: "
echo -n " Dumping database $i: " >> $QLOG
$NICE -n $PRI $MYSQL_DUMP -l -u$MYSQL_ROOTUN -p$MYSQL_ROOTPW $i > $BACKUP_PATH/$DATE/$DIR_PREFIX/$i.sql
arc $BACKUP_PATH/$DATE/$DIR_PREFIX/$i.sql $i.sql mysql
rm -f $BACKUP_PATH/$DATE/$DIR_PREFIX/$i.sql
fi
done
fi