mmarschall / s3db-backup

Backup and restore the database of your rails app to amazon S3, encrypting and compressing it on the fly
MIT License
21 stars 10 forks source link

{}[https://codeclimate.com/github/mmarschall/s3db-backup]

= s3db-backup for Rails

Its good practice to have a backup of your database ready at some other place than your production setup in case anything goes badly wrong there. And its a good idea to test your backups regularily. This gem will help you do both in a snap.

== Backup Your MySQL Database To Amazon S3

To get your data out of your own data center and store it somewhere save, amazon S3 is a great candidate. But, of course, you do not want to let anyone be able to read your application database. That's why s3db-backup is encrypting your dump before sending it to amazon S3.

== Requirements

As s3db-backup is using standard Unix tools for the heavy lifting, please make sure you have the following installed on your machine:

And, of course, you'll need to sign up for an Amazon S3 account and create a bucket using the AWS Management Console (or any other way)

== Getting Started

s3db-backup only supports MySQL databases and works from within a Rails application. Here are the steps to get you started:

This will generate the following files: config/s3_config.yml, db/secret.txt, and lib/tasks/db.rake

s3db-backup expects the buckets you name there to exist. Please make sure they do (using the Amazon AWS Management Console or any other Amazon Management Tool)

== Running a Backup

Dumping, encrypting, and uploading your current database is now as easy as typing one command:

$ rake s3db:backup

When its done, go to your amazon S3 bucket and see your shiny new backup file there!

== Restoring a Backup Using rake

To be able to fetch your backups from S3 and load them into your environment (development or production) you can use a set of rake tasks defined in lib/tasks/s3db_backup.rake:

Now you can either load that SQL dump with any tool you like or use a second rake task:

ATTENTION: This step will DROP your database and re-create it from your backup. Be careful when applying to your production environment. You have been warned!

$ rake s3db:latest:load

== Restoring a Backup Manually

I do not trust in backup systems, which do everything on their own. In emergency I want to be able to restore my data manually. As s3db-backup only uses standard Unix tools for the job, its pretty easy. Here are the steps to manually restore your database

Now you should have your DB restored.

== Note on Patches/Pull Requests

== Copyright

Copyright (c) 2010 - 2012 Matthias Marschall. See LICENSE for details.