From 018c467c69dd3c1d4f539a91b571fe44e7c290b9 Mon Sep 17 00:00:00 2001 From: riking Date: Wed, 25 Mar 2015 23:21:27 -0700 Subject: [PATCH] FIX: Stagger daily backups by up to 10 minutes --- .../create_daily_backup.rb} | 4 +--- app/jobs/scheduled/schedule_backup.rb | 12 ++++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) rename app/jobs/{scheduled/create_backup.rb => regular/create_daily_backup.rb} (80%) create mode 100644 app/jobs/scheduled/schedule_backup.rb diff --git a/app/jobs/scheduled/create_backup.rb b/app/jobs/regular/create_daily_backup.rb similarity index 80% rename from app/jobs/scheduled/create_backup.rb rename to app/jobs/regular/create_daily_backup.rb index 3c877cd38fd..40024fc76db 100644 --- a/app/jobs/scheduled/create_backup.rb +++ b/app/jobs/regular/create_daily_backup.rb @@ -1,8 +1,7 @@ require "backup_restore/backup_restore" module Jobs - class CreateBackup < Jobs::Scheduled - daily at: 3.hours + class CreateDailyBackup < Jobs::Base sidekiq_options retry: false def execute(args) @@ -11,4 +10,3 @@ module Jobs end end end - diff --git a/app/jobs/scheduled/schedule_backup.rb b/app/jobs/scheduled/schedule_backup.rb new file mode 100644 index 00000000000..7408641e54d --- /dev/null +++ b/app/jobs/scheduled/schedule_backup.rb @@ -0,0 +1,12 @@ + +module Jobs + class ScheduleBackup < Jobs::Scheduled + daily at: 3.hours + sidekiq_options retry: false + + def execute(args) + return unless SiteSetting.backup_daily? + Jobs.enqueue_in(rand(10.minutes), :create_daily_backup) + end + end +end