commit abc2ccc5098cd82f05eb12fdbfe533f6da5daba2
parent 46e42782f484ce22bc803494a6ea7d0ab57edb9e
Author: Florian Dold <florian@dold.me>
Date: Fri, 3 Jul 2026 17:07:39 +0200
exit backup script early if DB dump fails
Diffstat:
1 file changed, 5 insertions(+), 0 deletions(-)
diff --git a/roles/borg-start/templates/root/bin/borg-backup.sh b/roles/borg-start/templates/root/bin/borg-backup.sh
@@ -12,6 +12,11 @@ info "Dumping database"
sudo -u postgres pg_dumpall > postgres-backup.sql
db_exit=$?
+if [[ $db_exit -ne 0 ]]; then
+ info "DB export failed, exit status $db_exit"
+ exit 1
+fi
+
# Note: I actually benchmarked (!) this on *out* SQL data.
# zstd was fastest, but gzip was smallest
# (tested: gzip, bzip, zstd, lzip, xz)