sund / auto-gitlab-backup

A simple script to backup your Gitlab data. This script will copy the backup archives of your gitlab installation via rsync, or scp. Also, you can copy backups to Backblaze’s B2 Cloud Storage service.
http://sund.github.io/auto-gitlab-backup/
GNU General Public License v2.0
315 stars 73 forks source link

QuietRake option does not work #55

Open klasyc opened 2 years ago

klasyc commented 2 years ago

When i set quietRake=1 option in the configuration file, it is simply ignored and rake still prints lots of debug messages. After a quick research it turned out that the rake command is generated before the configuration file is actually loaded. The fix seems to be very simple, look at my patch which solves the issue for me:

diff --git a/auto-gitlab-backup.sh b/auto-gitlab-backup.sh
index 0faddad..d50f67a 100755
--- a/auto-gitlab-backup.sh
+++ b/auto-gitlab-backup.sh
@@ -41,12 +41,6 @@ gitlab_rails="/opt/gitlab/embedded/service/gitlab-rails"
 PDIR=$(dirname $(readlink -f $0))
 dateStamp=`date +"%F %H:%m:%S"`
 confFile="$PDIR/auto-gitlab-backup.conf"
-if [[ $quietRake == 1 ]]
-then
-  rakeBackup="gitlab-rake gitlab:backup:create CRON=1"
-else
-  rakeBackup="gitlab-rake gitlab:backup:create"
-fi

 ###
 ## Functions
@@ -95,6 +89,14 @@ archiveConfig() {
 rakeBackup() {
     echo ===== raking a backup =====
     cd $gitRakeBackups
+
+    if [[ $quietRake == 1 ]]
+    then
+      rakeBackup="gitlab-rake gitlab:backup:create CRON=1"
+    else
+      rakeBackup="gitlab-rake gitlab:backup:create"
+    fi
+
     $rakeBackup
 }

Anyway, thank you for a useful script. It saves me a lot of time!

sund commented 2 years ago

Thanks for the patch! Feel free to push a Pull Request. I have changed jobs so I haven't used this script for quite a while. If anyone would like to take over this, I would be glad to discuss it. Otherwise, this may be archived due to it no longer being relevant to my work.