Skip to content

Instantly share code, notes, and snippets.

@ziazek
Last active June 5, 2017 03:14
Show Gist options
  • Save ziazek/e74857a3cbf1dd875e280f46ad44324c to your computer and use it in GitHub Desktop.
Save ziazek/e74857a3cbf1dd875e280f46ad44324c to your computer and use it in GitHub Desktop.
Model.new(:deploy_phoenix_prod_backup, 'deploy_phoenix Production Backup') do
database PostgreSQL do |db|
db.name = "deployphoenix_prod"
db.username = "deployphoenix"
db.password = "mypassword"
db.host = "localhost"
db.port = 5432
# db.socket = "/tmp/pg.sock"
db.skip_tables = []
# db.only_tables = ["only", "these", "tables"]
db.additional_options = ["-xc", "-E=utf8"]
end
##
# Amazon Simple Storage Service [Storage]
#
# Hourly, daily, weekly, monthly backup rotation
time = Time.now
if time.hour == 0
if time.day == 1 # first day of the month
storage_id = :monthly
keep = 3
elsif time.sunday?
storage_id = :weekly
keep = 3
else
storage_id = :daily
keep = 6
end
else
storage_id = :hourly
keep = 23
end
store_with S3 do |s3|
s3.access_key_id = "my_access_key_id"
s3.secret_access_key = "my_secret_access_key"
s3.region = "us-east-1"
s3.bucket = "your-bucket-name"
s3.path = "/prod/#{storage_id}"
s3.keep = keep
end
##
# Gzip [Compressor]
#
compress_with Gzip
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment