diff --git a/roles/borg_client/templates/borg-backup.sh.j2 b/roles/borg_client/templates/borg-backup.sh.j2 index bfd62ce2add03b367416910b0a58b8abb52179ef..ade832c00413a89137cfcee9ebb872749ab3e026 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 \