4

One of my clients is running MySQL on a Windows Server 2008 system. Their regular backups are performed using StorageCraft's ShadowCopy, which uses the VSS service to perform backups of open files.

Some investigation indicates that MySQL is not entirely VSS-aware, and that the tables need to be locked prior to the shadow operation, then unlocked afterwards. There is a post at http://forum.storagecraft.com/Community/forums/p/548/2702.aspx which indicates the steps that need to be performed, however the user had some difficulty in performing them and no follow up solution was ever posted. Specifically, they succeeded in writing a batch file to lock the database, however once the batch file returns from MySQL it drops the connection and thus relinquishes the lock.

I'm looking for a method that I can send the MySQL command FLUSH TABLES WITH READ LOCK, then perform the backup, then send UNLOCK TABLES when the backup is complete.

Alternatively, I can exclude the MySQL data storage folder from backup, and schedule a mysqldump backup into a folder that will then be backed up by VSS.

Can I have some recommendations please?

1
  • It appears that you've listed a number of workable solutions right there in your question.
    – tylerl
    Nov 29, 2010 at 20:34

2 Answers 2

3

As the MySQL instruction "system " or "! " only works under linux your stuck with stoppig your service, take your vss snapshot and start the service.

The system command would allow to take the vss snapshot from within mysql so you don't lose locks. I believe it is used for LVM Snapshot backup.

0

Late answer, but I think I've found a way. At least, when I restored my copy made this way, it didn't complain about InnoDB log sequences being in the future or accuse me of shutting the server down improperly - though it did think a crash happened and recovered using the binary logs. YMMV, test your backups before you rely on them.

EDIT: Also not sure how helpful this will be for ShadowProtect, but maybe see if you can initiate the backup process from the command line and run this as a scheduled task. This will definitely help if you're looking to use VSS natively.

Here's the batch file I use, called flush_lock_vss.bat - M and L drives are for the data and binary logs respectively:

@echo off

echo FLUSH TABLES WITH READ LOCK;

vssadmin create shadow /for=m: >&2
vssadmin create shadow /for=l: >&2

echo UNLOCK TABLES;
echo \q

Pipe the input of this into a mysql process - run it as Administrator, of course:

C:\where\you\are> flush_lock_vss | C:\path\to\mysql-install\bin\mysql.exe -u username --password=TotallySecretPwd!

You will see the output for the vssadmin commands, but the FLUSH and UNLOCK commands will be sent to your MySQL instance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.