mysql-backup.sh will dump all of your MySQL databases, encrypt them using a GPG public key, transfer them to a S3 bucket, then delete them.
Getting Started:
- Install s3cmd ($ apt-get install s3cmd)
- Generate a GPG key and upload it to a key server. Remember the $KEY_ID and $KEY_NAME. (Google this. It's straightforward.)
- Download the GPG key onto the MySQL host server. ($ gpg --keyserver subkeys.pgp.net --recv-key $KEY_ID)
- Create a new keyring for this key. ($ gpg --export $KEY_NAME | sudo tee /etc/backups/keyring.gpg > /dev/null)
- Put mysql-backup.sh somewhere, and CHMOD 755 it. (/etc/backups/mysql-backup.sh is cool.)
- Test it. ($ ./etc/backups/mysql-backup.sh)
- Check your S3 bucket for the backup file, download it and decrypt it using the private key you made in Step 2.
- If everything worked, add this line to your crontab for backups at noon and midnight ($ crontab -e): "0 0,12 * * * /etc/backups/mysql-backup.sh". Otherwise, I'm @zcs on twitter.
That's it!