Last active
March 28, 2016 21:29
-
-
Save FUT/3f2178987b429a156585 to your computer and use it in GitHub Desktop.
Backup PSQL and S3
This file contains 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 characters
Logger.configure do | |
syslog.ident = File.dirname(__FILE__) + "/../../log/radium_backup" | |
end |
This file contains 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 characters
Model.new(:my_full_backup, 'Description for my_full_backup') do | |
database PostgreSQL do |db| | |
db.name = "my_database" | |
db.username = "user" | |
db.password = "pwd" | |
db.host = "localhost" | |
db.port = 5432 | |
db.additional_options = ["-xc", "-E=utf8"] | |
end | |
time = Time.now | |
if time.day == 1 # first day of the month | |
storage_id = :monthly | |
keep = 6 | |
elsif time.sunday? | |
storage_id = :weekly | |
keep = 3 | |
else | |
storage_id = :daily | |
keep = 12 | |
end | |
store_with S3, storage_id do |s3| | |
# AWS Credentials | |
s3.access_key_id = "key" | |
s3.secret_access_key = "secret" | |
# Or, to use a IAM Profile: | |
# s3.use_iam_profile = true | |
s3.region = "us-east-1" | |
s3.bucket = "my-backups" | |
s3.path = "backups/#{ storage_id }" | |
s3.keep = keep | |
end | |
notify_by Mail do |mail| | |
mail.on_success = false | |
mail.on_warning = true | |
mail.on_failure = true | |
mail.from = "[email protected]" | |
mail.to = "[email protected]" | |
mail.reply_to = "[email protected]" | |
mail.address = "smtp.sendgrid.net" | |
mail.port = 587 | |
mail.domain = "test.com" | |
mail.user_name = "user" | |
mail.password = "pwd" | |
mail.authentication = "plain" | |
mail.encryption = :starttls | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment