Tuesday, February 19, 2008

MySQL Backup to Amazon S3

Inspired by Alex King’s recent post on backups, I hacked together this short Perl script that will backup MySQL databases to Amazon’s excellent S3 storage system.

You can download it here. You will need to edit a few configuration items at the top of the script, to include your Amazon Web Services IDs and MySQL details. You will also need the Amazon::S3 and DBI perl modules. You can get them from CPAN.

$ wget -Omysql_s3.pl http://dparrish.com/files/mysql_s3.pl
$ vi mysql_s3.pl (enter your details)
$ chmod 755 mysql_s3.pl
$ ./mysql_s3.pl

It’s probably best to add it to cron so it will run daily. Something like this works nicely:

0 3 * * * perl /home/dparrish/mysql_s3.pl

I’d also suggest using S3 Firefox Organizer to manage your S3 account. It’s a Firefox plugin.


Courtney said...


I get a 403/forbidden error when I try to download the script from here http://dparrish.com/files/mysql_s3.pl

Can you make it available?

Thanks! :)

dparrish said...

Thanks for noticing, it's available again now.