On Thu, 2009-03-05 at 11:25 +0000, Mark Rogers wrote:
What I want to do is write a script to backup some databases, but only if they've changed. I figured that the easiest way to get a list of databases that exist, as well as which have changed, is to look in /var/lib/mysql for directories with recently changed files.
I know that find /var/lib/mysql -type d -mtime 1 .. will find directories that have changed inside 24 hours, but it does not pick up directories whose contents have changed.
Any suggestions?
Is it wise to be backing up mysql from the data pool directly ? What if the DB does something during your copy operation ? The DB would then be inconsistent surely.
If you have space on the server why not run a dump every night at a scheduled time and then rsync this dump file (therefore only moving changes) as your backup script. That way you have a convenient less than day old offline copy actually on the machine for the "whoops I didn't mean to drop that table" and your off machine backups synced via rsync/rsync-ssh for when the machine itself goes pop.