Created
November 12, 2019 10:43
-
-
Save absk1317/982d428f2e649ac60ad3edbb0e96a1a5 to your computer and use it in GitHub Desktop.
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
# encoding: utf-8 | |
Model.new(:producion_backup, 'Description for producion_backup') do | |
archive :configs do |archive| | |
archive.add "/home/ubuntu/projects/api/shared/config/" | |
archive.add '/etc/nginx/' | |
end | |
database PostgreSQL do |db| | |
db.name = "db_name" | |
db.username = "db_username" | |
db.password = "db_password" | |
db.host = "db_url.ap-south-1.rds.amazonaws.com" # or localhost, or anyother hosted service url | |
db.port = 5432 # or any other port that you might have | |
end | |
# Keep 4 monthly backups | |
# 6 weekly | |
# 7 daily | |
# and 23 daily backups | |
time = Time.now | |
if time.hour == 0 | |
if time.day == 1 # first day of the month | |
storage_id = :monthly | |
keep = 4 | |
elsif time.sunday? | |
storage_id = :weekly | |
keep = 7 | |
else | |
storage_id = :daily | |
keep = 6 | |
end | |
else | |
storage_id = :hourly | |
keep = 23 | |
end | |
store_with S3 do |s3| | |
# AWS Credentials | |
s3.access_key_id = "AWS_access_key_id" | |
s3.secret_access_key = "AWS_secret_access_key" | |
s3.region = "ap-south-1" | |
s3.bucket = "db-backups" | |
s3.path = "/backups/#{storage_id}" | |
s3.keep = keep | |
end | |
# can use mattermost/Flock or anyother servicee that takes in webhooks. | |
notify_by Slack do |slack| | |
slack.on_success = true | |
slack.on_failure = true | |
slack.webhook_url = 'Webhook URL' | |
slack.username = 'Backup bot' | |
slack.channel = 'db-backup-alerts' | |
slack.icon_emoji = ':ice:' | |
end | |
compress_with Gzip | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment