From 7c66a32971b2607817d039b3b807e76b43d3463f Mon Sep 17 00:00:00 2001 From: Tom Young Date: Thu, 28 Jan 2021 16:46:08 +0000 Subject: [PATCH] Filter out pgdump-custom warnings from the logs. E.g. from timescaledb, See https://github.com/timescale/timescaledb/issues/1581 --- scripts/pg_backup_rotated.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/pg_backup_rotated.sh b/scripts/pg_backup_rotated.sh index 6d1ee1c..be2fe81 100755 --- a/scripts/pg_backup_rotated.sh +++ b/scripts/pg_backup_rotated.sh @@ -139,11 +139,15 @@ function perform_backups() if [ $ENABLE_CUSTOM_BACKUPS = "yes" ]; then echo "* Custom backup of $DATABASE" - if ! pg_dump -Fc -h "$HOSTNAME" -U "$USERNAME" "$DATABASE" -f $FINAL_BACKUP_DIR"$DATABASE".custom.in_progress; then + set -o pipefail + # NB - we are using this to back up TimescaleDB which results in loads of warnings. Any actual errors seem to start with the string "error" + # so grep them out. The command will fail and print an error anyway, this is just filtering what the preceding log lines will say. + if ! pg_dump -Fc -h "$HOSTNAME" -U "$USERNAME" "$DATABASE" -f $FINAL_BACKUP_DIR"$DATABASE".custom.in_progress 2>&1 | (grep 'error' || true); then echo "[!!ERROR!!] Failed to produce custom backup database $DATABASE" else mv $FINAL_BACKUP_DIR"$DATABASE".custom.in_progress $FINAL_BACKUP_DIR"$DATABASE".custom fi + set +o pipefail fi done echo -e "\nAll database backups complete"