aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Spek <p.spek@tyil.nl>2022-05-26 21:41:05 +0200
committerPatrick Spek <p.spek@tyil.nl>2022-05-26 21:41:05 +0200
commit52230d0f94f6b4f1e221ced1f1de7358138d8713 (patch)
tree6b874524242866a0aa965fdd797450c9f4e187a7
parent838ca850c488fdd9ed69c2aa2a64cf50f1fca80d (diff)
Add more logging to postgresql backups
-rw-r--r--lib/subcommands/backup.bash38
1 files changed, 26 insertions, 12 deletions
diff --git a/lib/subcommands/backup.bash b/lib/subcommands/backup.bash
index f454a4b..d717779 100644
--- a/lib/subcommands/backup.bash
+++ b/lib/subcommands/backup.bash
@@ -134,23 +134,37 @@ backup_database_postgresql() {
[[ $database == "postgres" ]] && continue
[[ $database =~ template* ]] && continue
+ local cmd_create
+ local cmd_prune
+
# Prune old backups
info "$BASHTARD_NAME/backup/$index" "Pruning PostgreSQL backups of $database in $repo"
- $borg prune \
- --keep-daily "$(config "bashtard.backup.keep.daily")" \
- --keep-weekly "$(config "bashtard.backup.keep.weekly")" \
- --keep-monthly "$(config "bashtard.backup.keep.monthly")" \
- --keep-yearly "$(config "bashtard.backup.keep.yearly")" \
- --prefix "$database-" \
- --remote-path "$remote" \
+ cmd_prune=(
+ "$borg" "prune"
+ "--keep-daily" "$(config "bashtard.backup.keep.daily")"
+ "--keep-weekly" "$(config "bashtard.backup.keep.weekly")"
+ "--keep-monthly" "$(config "bashtard.backup.keep.monthly")"
+ "--keep-yearly" "$(config "bashtard.backup.keep.yearly")"
+ "--prefix" "$database-"
+ "--remote-path" "$remote"
"$repo/postgresql-$database"
+ )
+
+ notice "$BASHTARD_NAME/backup/$index" "> ${cmd_prune[*]}"
+ ${cmd_prune[@]}
# Create new backups
info "$BASHTARD_NAME/backup/$index" "Writing new PostgreSQL backup of $database to $repo"
- pg_dump "$database" \
- | borg create \
- --remote-path "$remote" \
- "$repo/postgresql-$database::$database-$(datetime)" \
- -
+ cmd_create=(
+ "borg" "create"
+ "--remote-path" "$remote"
+ "--content-from-command"
+ "$repo/postgresql-$database::$database-$(datetime)"
+ "--"
+ "pg_dump" "$database"
+ )
+
+ notice "$BASHTARD_NAME/backup/$index" "> ${cmd_create[*]}"
+ ${cmd_create[@]}
done < <(psql -AXt -d template1 -c "SELECT datname FROM pg_database")
}