gem install backup
- Check available commands for generator
backup help generate:model
- Generate backup model. I chose backup to s3, you may choose any of available in docs.
backup generate:model --trigger=app_backup --databases='postgresql' --storages='s3' --compressor='gzip' --notifiers='mail'
- Following backup docs you can configure any kind of options for your specific case. My example is in
app_backup.rb
file
- As you setup all the options, check the backup execution
backup perform -t app_backup
- To run backups on a schedule we need to install whenever
gem install whenever
- When that finishes, create a
/config
directory for Whenever inside ~/Backup
:
cd ~/Backup
mkdir config
wheneverize .
- This will create a schedule.rb file in
~/Backup/config
for writing your cron jobs. Below is the code I added to mine:
every 1.day, :at => '11:30 pm' do
command "backup perform -t app_backup"
end
- Cron will run the
backup perform -t app_backup command
. If you’d like to see this converted to cron syntax, run whenever
:
$ whenever
30 23 * * * /bin/bash -l -c 'backup perform -t app_backup >> /home/bob/Backup/config/cron.log 2>&1'
- To write all the jobs to crontab we need to run:
whenever --update-crontab