This is a COPIOUS script to backup a Magento instance. It pulls uploaded media and an SQL dump, compresses them, and copies them to an Amazon S3 bucket. The intent is to provide Magento operators with the ability to do a full “point in time” restore.
This requires ruby and rubygems, first and foremost. If you don't have those installed already, you'll want to download and install them:
Ruby will need the OpenSSL libraries. If you haven’t installed them, do this (Ubuntu):
$ sudo apt-get install libopenssl-ruby
$ gem install bundler $ bundle install
If you're not using those tools, have sudo access and do this:
$ sudo gem install right_aws
Back it up.
To use it, drop your authentication vectors into a
magento_backup.yml file to look like this:
site_name: your_app_name database: ssh_username: your_ssh_username db_username: your_mysql_username password: your_password hostname: your_app.staging.copiousdev.com database: your_app_staging dump_arguments: --single-transaction -e amazon: bucket: your_app_backups secret_access_key: your_secret access_key_id: your_key_id webserver: username: your_ssh_username hostname: your_app.staging.copiousdev.com app_root: /var/www/your_app-staging media_path: /var/www/your_app-staging/media paths_to_exclude: - var
Once that's in place, run the script:
$ bundle exec ruby ./magento_backup.rb
It should produce output roughly equivalent to this:
Creating backup magento_backup_2011-10-27... - backing up uploaded assets... done. - putting up maintenance notice... done. - backing up database... done. - removing maintenance notice... done. - excluding paths... done. - compressing backup... done. - splitting backups... done. - uploading to amazon cloud... done. - removing local copy of the backup... done. done.
To restore from a backup, you'll first need to pull all of the partitioned backup files back down from Amazon S3 using their web client at http://aws.amazon.com/. Once you have a local copy of these, you'll need to reassemble them into a tgz file:
$ cat `ls magento_backup_2012-06-14.tgz.*` ... > magento_backup_2012-06-14.tgz
Then you'll need to extract the archive using tar and gzip:
$ tar zxvf magento_backup.tgz
This will create a directory containing the assets, code, and database dump of the backup Magento data.
This software is available under the Academic Free License, version 3.0: