From 8fd099d45f1fc47766ccd7b7a0c66d95c3fd7599 Mon Sep 17 00:00:00 2001 From: Sameer Naik Date: Sat, 19 Dec 2015 23:37:22 +0530 Subject: [PATCH] create automatic backups job only if it does not already exist --- assets/runtime/functions | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/assets/runtime/functions b/assets/runtime/functions index dc4169b1..40211ebf 100644 --- a/assets/runtime/functions +++ b/assets/runtime/functions @@ -549,21 +549,21 @@ gitlab_configure_sidekiq() { gitlab_configure_backups_cron() { case ${GITLAB_BACKUP_SCHEDULE} in daily|weekly|monthly) - echo "Configuring gitlab::backups::cron..." - read hour min <<< ${GITLAB_BACKUP_TIME//[:]/ } - day_of_month=* - month=* - day_of_week=* - case ${GITLAB_BACKUP_SCHEDULE} in - daily) ;; - weekly) day_of_week=0 ;; - monthly) day_of_month=01 ;; - esac - exec_as_git cat >> /tmp/cron.${GITLAB_USER} </tmp/cron.${GITLAB_USER} 2>/dev/null) || \ + ! $(grep -q 'bundle exec rake gitlab:backup:create' /tmp/cron.${GITLAB_USER}) ]]; then + echo "Configuring gitlab::backups::cron..." + read hour min <<< ${GITLAB_BACKUP_TIME//[:]/ } + day_of_month=* + month=* + day_of_week=* + case ${GITLAB_BACKUP_SCHEDULE} in + daily) ;; + weekly) day_of_week=0 ;; + monthly) day_of_month=01 ;; + esac + echo "$min $hour $day_of_month $month $day_of_week /bin/bash -l -c 'cd ${GITLAB_INSTALL_DIR} && bundle exec rake gitlab:backup:create RAILS_ENV=${RAILS_ENV}'" >> /tmp/cron.${GITLAB_USER} + crontab -u ${GITLAB_USER} /tmp/cron.${GITLAB_USER} + fi rm -rf /tmp/cron.${GITLAB_USER} ;; esac