Backup your MySQL databases and your user folder on your mac with Automator

Posted by Joel Jensen Sat, 19 Aug 2006 02:15:00 GMT

I have been backing my stuff up weekly using an applescript. But ran into a wall trying to automate the mysql backup. The issue is I have ALOT of development databases and I do not want a single dumpfile, else I would have to blow away and rebuild everything if I needed a refresh of one table. I wrote this nifty automator script.

  • 1 Basicly the steps are drag Automator::Run Shell Script.
  • 2 Fill in the script.
  • 3 Drag Mail::New Message and send confirmation to yourself. I would have preferred to add an event to iCal but there is no Time.now() feature in the iCal Automator actions, so my system would always be backed up freshly August 18th 2006 at 12:50 pm, This is a problem.
  • 4 Drag the Mail::Send Outgoing Messages
  • 5 Save as a workflow Automator Here is the script from step one. It asssumes there is no root password. I never open my laptop up to the world so a password is a hassle.

I created a directory in /Users/joel/backup_mysql/ to hold the archived mysql I created a directory in /Volumes/DROPSHIP/backup to archive to ( This is an external firewire drive )

for x in `/usr/local/mysql/bin/mysql -u root -Bse "show databases"`; do
/usr/local/mysql/bin/mysqldump -u root $x | /sw/bin/gzip -9 > /Users/joel/backup_mysql/$x.gz
done;
/usr/bin/rsync -aE --delete ~ /Volumes/DROPSHIP/backup 2>>~/rsyncErr.txt || echo -n;

To execute, rightclick :: Automator :: Backup Laptop … run Automator

Comments

Leave a comment

Comments