Daniel Doubrovkine bio photo

Daniel Doubrovkine

aka dB., @awscloud, former CTO @artsy, +@vestris, NYC

Email Twitter LinkedIn Github Strava
Creative Commons License

This is the last piece of the dev-ops puzzle. We want our MongoDB backup to run nightly. Let’s create a :cron task

task :cron => :environment do
  Rake::Task['db:production:backup'].invoke
end

We are going ot use whenever to avoid the ugly syntax of cron. Whenever is configured in config/schedule.rb.

set :output, "/tmp/cron_log.log"

every 1.day, :at => '3:30 am' do
  rake 'cron'
end

To propagate the settings to crontab, use the following command.

$ whenever --update-crontab

All credit for this one goes to @sarcilav – I wanted to wrap up our dev-ops story in one place on my blog.