Archive

Archive for the ‘shell script’ Category

 <

Easily Back Up MySQL Databases to Amazon S3

April 8th, 2009

tarball: dbbak.tar.gz

I wrote this script as a very simple way to take any MySQL server and back up all the databases matching a certain name pattern, using a single command and no extra parameters. Simply log onto your server, run dbbak.sh and you have a new DB snapshot on your file system, and a copy somewhere on the Amazon cloud in case your server melts down.

The cool thing is that once you are set up, you don’t have to worry about naming your backups, or where to store them. Names are generated automatically based on the date and time, and the name of the server (arbitrarily set by you). The files are compressed, and saved on S3 as well.

Saving to S3 is performed by another-s3-bash, which is included in the tarball above.

update, 2009/10/04: I cleaned up the main shell script and the INSTALL instructions. In some cases the s3 client does not seem to be able to connect to AWS S3. I have not debugged that yet.