Question about sysbk

webquarry

Verified User
Joined
Mar 19, 2004
Messages
171
I see that sysbk does a full file-by-file copy of /var/lib/mysql. It stops the mysql daemon before doing the copy to make sure that the files are not in use thus ensuring that we do not get a corrupt copy.

My question is this: Given that dataskq restarts the mysql daemon as soon as it notices that mysqld is down, won't that mess up the copies if the copies are not complete before the db starts up again?
 
Last edited:
I'm not sure how DA handles it, but if they did not have sysbk temporarily disable monitoring, then yes it could be a problem. Have you had any backups that take more than 1min to backup all of the mysql databases?
 
No not yet, but give the users time and someone will create a db that takes longer than a minute to copy...
 
Last edited:
I don't believe sysbk stops DA monitoring.

If someone doesn't add it soon, I guess I'll look into it.

After all the other stuff on my plate.

How about someone else who understands the internals of sysbk?

Don't forget it needs to be done only during the mysql backup.

Jeff
 
Sysbk looks like a simple shell script. If someone can tell me how to kill da monitoring, I'll add it to sysbk's mysql module.
 
Last edited:
Be careful where you put it; it should only be off while mysql is being backed up.

I don't think DA has a separate monitor (you might send an email to support and ask them); so you should shutdown DA

(on linux): service directadmin stop

and then bring it back up

(on linux): service directadmin start

Jeff
 
Nope.

service directadmin stop

does indeed stop directadmin but it just starts itself (and any other services that you have stopped such as mysql) the next time that dataskq runs.

If you turn mysqld off in the admin control panel, it stays off. Anyone know how to accomplish the same results from the command line?
 
Hello,

The software that the dataskq keeps and eye on is setup in the /usr/local/directadmin/data/admin/services.status file. If you set the software to OFF, then the dataskq will not try and restart it.

If you stop the software through the Admin Panel in DA, then that software is set to OFF in that file. Similarly with "start" through the Admin Panel, that software would be set to ON.

John
 
Webquarry,

You're right <frown>.

I've looked and looked, and I can't find where DA runs dataskq.

John, could you help us by telling us where it is?

For most of us turning it off for a minute or so in the middle of the night during a backup is a bit easier than making changes to a control file.

Thanks.

Jeff
 
Ok, so just edited the appropriate line in that file and then killing mysqld will shut the database down until I re-edit the appropriate line in that file back to ON?
 
Yes.

When you write a script to automate that, please be kind enough to post it for us.

If you do that, I'll integrate it into the DA implementation of sysbk.

Jeff
 
dataskq is run by cron, for me at least (FreeBSD)
So I think it would be better to set the service.status to OFF in a pre backup script of some sort that prepares the system for a complete backup, instead of trying to shutdown dataskq. An even better idea is to have the prepare script only stop/deactivate services that are affected during backups. (For instance if only MySQL is backed up with sysbk there is no need to stop all services)
 
jmstacey said:
dataskq is run by cron, for me at least (FreeBSD)
It might be for me as well (RHEL 3), but I can't find it :( .
So I think it would be better to set the service.status to OFF in a pre backup script of some sort that prepares the system for a complete backup, instead of trying to shutdown dataskq. An even better idea is to have the prepare script only stop/deactivate services that are affected during backups. (For instance if only MySQL is backed up with sysbk there is no need to stop all services)
My thought is if dataskq wasn't run for the very few minutes it takes to backup the mysql databases that wouldn't really be a problem; for most of us it's under a minute anyway.

I agree with you that a script would be nice, but editing certain lines of a file isn't as clean to me; as the whole layout of the file could change.

Sure it could be done with a simple one-line edit, and if someone creates what looks like a foolproof script I'll be happy to integrate it into the right spot in sysbk so it'll only happen while mysql is being backed up.

Jeff
 
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
 
Last edited:
Back
Top