Skip to content

Commit

Permalink
Filter out pgdump-custom warnings from the logs.
Browse files Browse the repository at this point in the history
E.g. from timescaledb, See timescale/timescaledb#1581
  • Loading branch information
Tomcat-Engineering committed Jan 28, 2021
1 parent c3f7f71 commit 7c66a32
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion scripts/pg_backup_rotated.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 7c66a32

Please sign in to comment.