S3 backups using BACKUP-Gem

S3 backups using BACKUP-Gem

595

Install rubygems:
$ yum install -y rubygems

Install the backup gem:
$ gem install backup

Install dependencies for backup gem:
$ yum install ruby-devel
$ yum install -y rubygem-nokogiri
$ yum install -y gcc ruby-devel libxml2 libxml2-devel libxslt libxslt-devel
$ gem install fog -v ‘~> 1.4.0’
$ gem install parallel -v ‘~> 0.5.12’
$ gem install mail -v ‘~> 2.4.0’

Generate a backup model:
$ backup generate:model –trigger <server hostname> –storages=’s3′

Edit the systems backup model to configure settings:
$ vim /root/Backup/system_hostname.rb

Modify backup model:
Change split_into_chunks_of value from “250” to “4000”.
(This specifies the upper single entity file size limit)

Remove default store_with S3 DSL block and replace with the following:

sync_with Cloud::S3 do |s3| s3.access_key_id = "my_access_key_id" s3.secret_access_key = "my_secret_access_key" s3.bucket = "my-bucket" s3.path = "/backups" s3.mirror = true s3.directories do |directory| directory.add "/var/apps/my_app/public/videos" directory.add "/var/apps/my_app/public/music" end end
(Modify accordingly to match the S3 URI details and the directories you want to add)

Add email notification options to the backup model:

notify_by Mail do |mail|
mail.from = '-@-'
mail.address = 'smtp.gmail.com'
mail.port = 587
mail.user_name = ''
mail.password = ''
mail.authentication = 'plain'
mail.enable_starttls_auto = true
mail.to = ''
mail.on_success = false
mail.on_warning = false
mail.on_failure = true
end

Install “whenever” ruby cron gem:
$ gem install whenever

Schedule “whenever” job to execute backup model:
$ touch /tmp/schedule.rb

Add the following to the schedule.rb file:

every 15.minutes do
command "backup perform --trigger <backup model name>"
end

Install the “whenever” cronjob:
$ whenever –update-crontab <backup model name>