From 4bc877e6cea78c4dccb7035ef0dfe09032413110 Mon Sep 17 00:00:00 2001 From: Evangelos Foutras <evangelos@foutrelis.com> Date: Mon, 28 Jun 2021 08:59:47 +0300 Subject: [PATCH] Create snapshot with current db and gitlab backups The helper scripts that create mysql/postgres database dumps as well as the script running gitlab-backup were executed after the btrfs snapshot was taken. This resulted in stale db and gitlab backups (from last run). Move execution of these helper scripts further up so their outputs get included in the btrfs snapshot. Reported-by: Kristian Klausen <kristian@klausen.dk> --- roles/borg_client/templates/borg-backup.sh.j2 | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/roles/borg_client/templates/borg-backup.sh.j2 b/roles/borg_client/templates/borg-backup.sh.j2 index bfd62ce2a..ade832c00 100644 --- a/roles/borg_client/templates/borg-backup.sh.j2 +++ b/roles/borg_client/templates/borg-backup.sh.j2 @@ -39,6 +39,17 @@ cleanup() { trap cleanup EXIT +# Dump databases to /root/backup-{postgres,mysql} before taking a btrfs snapshot +systemctl is-active postgresql && /usr/local/bin/backup-postgres.sh || true +if systemctl is-active mysqld || systemctl is-active mariadb; then + /usr/local/bin/backup-mysql.sh || true +fi + +{% if inventory_hostname == "gitlab.archlinux.org" %} +# Create tarball backups of various GitLab directories using the official backup tool +systemctl is-active docker && /usr/local/bin/backup-gitlab.sh +{% endif %} + if is_btrfs "$src"; then # List all btrfs submounts we want to backup, e.g. homedir.archlinux.org with "/ /home" list_of_btrfs_submounts=$(findmnt -Rl -o target,fstype,options / | grep btrfs | grep -v docker | grep -v "subvol=\/[[:alnum:]]" | cut -d ' ' -f1) @@ -62,15 +73,6 @@ else backup_mountdir="$src" fi -systemctl is-active postgresql && /usr/local/bin/backup-postgres.sh || true -if systemctl is-active mysqld || systemctl is-active mariadb; then - /usr/local/bin/backup-mysql.sh || true -fi - -{% if inventory_hostname == "gitlab.archlinux.org" %} -systemctl is-active docker && /usr/local/bin/backup-gitlab.sh -{% endif %} - borg create -v --stats -C zstd \ -e /proc \ -e /sys \ -- GitLab