Getting rid of the backupninja warnings on gitlab backup
I did some more investigation and discovered that:
- backupninja greps for the words Warning, Error, Fatal, Halt, and Info in the output of shell backup scripts. Then, it records a problem based on those words. This probably works fine for most backupninja handlers since they are run by backupninja code that can properly check error codes and output the right words when necessary. But it doesn't work well for shell scripts - since they could output anything. Or, nothing if there really is a problem.
- gitlab-backup always outputs:
Warning: Your gitlab.rb and gitlab-secrets.json files contain sensitive data and are not included in this backup. You will need these files to restore a backup. Please back them up manually. Backup task is done.
Clearly this is not a warning we need to be warned about every time the backup runs. I took a look at the underlying file being called (/opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/backup.rake) and I don't see any obvious ways to pass an argument to silence it.
So... my best idea would be to change /etc/backup.d/10_backup-gitlab.sh to read:
gitlab-backup create BACKUP=dump GZIP_RSYNCABLE=yes SKIP=tar | grep -v "Warning: Your gitlab.rb and gitlab-secrets.json files
It seems kinda awkward, but it should only eliminate the warning that we expect. But I'm not sure how else to convince backupninja that there really is no warning that we should know about.
Since backupninja really depends on scripts to output the words "Warning, Error, etc" - a more complete fix might be more along the lines of:
out=$(gitlab-backup create BACKUP=dump GZIP_RSYNCABLE=yes SKIP=tar)
if [ "$?" -ne "0" ]; then
printf "Fatal: %s\n" "$out"
fi
This way we can rely on the exit code of the gitlab backup script - which I assume will be non-zero if there really is a problem and "0" if there is not a problem.