Skip to content

Instantly share code, notes, and snippets.

@simaob
Created July 19, 2011 12:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simaob/1092102 to your computer and use it in GitHub Desktop.
Save simaob/1092102 to your computer and use it in GitHub Desktop.
Backup config file for db_name
# Begin Whenever generated tasks for: backups
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
32 11 * * * /bin/bash -l -c 'backup perform -t db_name -c ~/Backup/db_name.rb >> ~/Backup/log/whenever_cron.log 2>&1'
0 0 1 12 * /bin/bash -l -c 'backup perform -t db_name -c ~/Backup/db_name_yearly.rb >> ~/Backup/log/whenever_cron.log 2>&1'
0 0 1 * * /bin/bash -l -c 'backup perform -t db_name -c ~/Backup/db_name_monthly.rb >> ~/Backup/log/whenever_cron.log 2>&1'
# End Whenever generated tasks for: backups
Backup::Model.new(:db_name, 'Backup db_name Production db') do
##
# PostgreSQL db_name
#
database PostgreSQL do |db|
db.name = "[db_name]"
db.username = "[db_username]"
db.password = "[db_password]"
db.host = "localhost"
db.port = 5432
end
##
# Amazon Simple Storage Service [Storage]
store_with S3 do |s3|
s3.access_key_id = '[s3_access_key]'
s3.secret_access_key = '[s3_secret_access_key]'
s3.region = '[s3_region]'
s3.bucket = '[s3_bucket]'
s3.path = '/daily' #/monthly, /yearly
s3.keep = 30
end
##
# Gzip [Compressor]
#
compress_with Gzip do |compression|
compression.best = true
compression.fast = false
end
##
# Mail [Notifier]
#
notify_by Mail do |mail|
mail.on_success = true
mail.on_failure = true
mail.from = 'db_backup@domain'
mail.to = 'helpdesk@unep-wcmc.org'
mail.address = 'localhost'
mail.port = 25
mail.domain = 'domain'
mail.user_name = nil
mail.password = nil
mail.authentication = 'plain'
mail.enable_starttls_auto = true
end
end
# Use this file to easily define all of your cron jobs.
#
# It's helpful, but not entirely necessary to understand cron before proceeding.
# http://en.wikipedia.org/wiki/Cron
# Example:
#
env :PATH, "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
set :output, "~/Backup/log/whenever_cron.log"
["db_name"].each do |db|
every 1.day, :at => '11:32 am' do
command "backup perform -t #{db} -c ~/Backup/#{db}.rb"
end
every 1.month do
command "backup perform -t #{db} -c ~/Backup/#{db}_monthly.rb"
end
every 12.month do
command "backup perform -t #{db} -c ~/Backup/#{db}_yearly.rb"
end
end
# Learn more: http://github.com/javan/whenever
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment