Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

This is a COPIOUS script to backup a Magento instance.

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 .gitignore
Octocat-spinner-32 .ruby-gemset
Octocat-spinner-32 .ruby-version
Octocat-spinner-32 Gemfile
Octocat-spinner-32 Gemfile.lock
Octocat-spinner-32 README.md
Octocat-spinner-32 magento_backup.rb
Octocat-spinner-32 magento_backup.yml.sample
README.md

Magento Backup

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.

Prerequisites

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

This also requires the Amazon S3 ruby gem to be present. Assuming you're using RVM and Bundler, do this:

    $ 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.

Restoring

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.

License

This software is available under the Academic Free License, version 3.0:

http://www.opensource.org/licenses/afl-3.0.php

Something went wrong with that request. Please try again.