Skip to content

Instantly share code, notes, and snippets.

@chrismealy
Created February 13, 2012 05:41
Show Gist options
  • Save chrismealy/1813976 to your computer and use it in GitHub Desktop.
Save chrismealy/1813976 to your computer and use it in GitHub Desktop.
rails backup
#
# Backup
# Generated Template
#
# For more information:
#
# View the Git repository at https://github.com/meskyanichi/backup
# View the Wiki/Documentation at https://github.com/meskyanichi/backup/wiki
# View the issue log at https://github.com/meskyanichi/backup/issues
#
# When you're finished configuring this configuration file,
# you can run it from the command line by issuing the following command:
#
# $ backup -t my_backup [-c <path_to_configuration_file>]
database_yml = File.expand_path('../config/database.yml', __FILE__)
RAILS_ENV = ENV['RAILS_ENV'] || 'development'
require 'yaml'
config = YAML.load_file(database_yml)
Backup::Model.new(:db_backup, 'Database Backup to S3') do
database PostgreSQL do |db|
db.name = config[RAILS_ENV]["database"]
db.username = config[RAILS_ENV]["username"]
db.password = config[RAILS_ENV]["password"]
db.host = config[RAILS_ENV]["host"]
db.port = config[RAILS_ENV]["port"]
db.skip_tables = []
end
store_with S3 do |s3|
s3.access_key_id = '<SECRET>'
s3.secret_access_key = '<SECRET>'
s3.region = 'us-east-1'
s3.bucket = '<BUCKET NAME>'
s3.path = config[RAILS_ENV]["database"]
s3.keep = 10
end
compress_with Gzip do |compression|
compression.best = true
compression.fast = false
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment