Latest update: Nov 28 2007 ( patch submitted by Cyril Mougel)
- fixed : ar-backup not working properly when the OS isn't in English (svn issues)
- fixed : can't create a backup folder on windows when the revision isn't defined
- enhanced : speed has been improved since we are now parsing the local svn files.
Active Record backup is a Rails plugin which lets you backup your database schema and content in a schema.rb file and fixtures.
Backups are organized by environments and SVN revision.
ar-backup is compatible with sake http://errtheblog.com/post/6069
To install in Rails:
Rails script:
ruby script/plugin install http://ar-backup.googlecode.com/svn/ar-backup
Piston:
piston import http://ar-backup.googlecode.com/svn/ar-backup vendor/plugins/ar-backup
SVN:
svn co http://ar-backup.googlecode.com/svn/ar-backup vendor/plugins/ar-backup
Sake:
sake -i http://ar-backup.googlecode.com/svn/ar-backup/tasks/ar_backup_tasks.sake
Prerequisites:
Your project must be under subversion
Usage:
rake backup:db:dump # create a backup folder containing your db schema and content data (see backup/{env}/build{build number})
rake backup:db:extract_content # Create YAML fixtures from your DB content
rake backup:db:extract_schema # Dump the db schema
rake backup:db:load # load your backed up data from a previous build. rake backup:db:load BUILD=1182 or rake backup:db:load BUILD=1182 DUMP_ENV=production
Backup your database content and schema. (development environment)
rake backup:db:dump
Do the same thing but with the production environment (note that the previous backup won't be overwritten)
RAILS_ENV=production rake backup:db:dump
Restore the database content and schema backed up under BUILD=2547
rake backup:db:load BUILD=2547
Restore the production database backup into our development db
rake backup:db:load BUILD=2547 DUMP_ENV=production
Capistrano 2 usage example
(you first need to create a backup folder)
set :backup_dir, "#{deploy_to}/backup"
before :deploy dodb.backup db.move_backupend
namespace :db dodesc 'create the production database' task :create dorun "cd #{current_release} && rake db:create RAILS_ENV=production"end
desc 'dump the database schema and content' task :backup dorun "cd #{current_release} && rake backup:db:dump RAILS_ENV=production"end
desc 'timestamp the backup file' task :move_backup dorun "cd #{current_release} && mv backup/production #{backup_dir}/production#{Time.now.strftime("%Y-%m-%d%H-%M")}"end
end