Created
February 19, 2013 10:09
-
-
Save anonymous/4984592 to your computer and use it in GitHub Desktop.
Revisions
-
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ #... gem 'backup', require: false, github: 'kavu/backup', branch: 'bump_fog_version', ref: 'c3fd8e6eb4f464de1c8' gem 'whenever', require: false #... This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,49 @@ # encoding: utf-8 require 'backup' RAILS_ENV = ENV['RAILS_ENV'] || 'development' config = YAML.load_file File.expand_path('../database.yml', __FILE__) Backup::Storage::S3.defaults do |s3| s3.access_key_id = '...' s3.secret_access_key = '...' s3.region = '...' s3.bucket = '...' s3.keep = 25 end Backup::Model.new(:postgres, 'Backup PostgreSQL database 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.path = config[RAILS_ENV]["database"] end compress_with Bzip2 split_into_chunks_of 250 end Backup::Model.new(:redis, 'Backup Redis database to S3') do database Redis do |db| db.path = "..." db.invoke_save = true end store_with S3 do |s3| s3.path = "myapp_#{RAILS_ENV}" end compress_with Bzip2 split_into_chunks_of 250 end This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ #... require 'whenever/capistrano' #... set :whenever_command, "bundle exec whenever" set :bundle_flags, "--deployment --quiet --binstubs" set :default_environment, { 'PATH' => "$HOME/.rbenv/shims:$HOME/.rbenv/bin:$PATH" } #... namespace :rbenv do task :rehash do run 'rbenv rehash' end end task :backup do run "cd #{current_path} && bundle exec rake backup RAILS_ENV=#{rails_env}" end #... after "bundle:install", "rbenv:rehash" This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ # encoding: utf-8 set :output, "log/cron.log" every 1.day, at: '04:00' do rake 'backup' end This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,5 @@ desc "Back Postgres and Redis" task :backup do # Yeah, it's an ugly looking command sh "bundle exec backup perform -q -t postgres,redis --config-file config/backup.rb --root-path . --tmp-path public/system/backup/tmp --cache-path public/system/backup/cache --data-path public/system/backup/data" end This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ # How to make Rails + Backup + Whenever + Capistrano (and rbenv) work.