#!/bin/bash # Installed at /usr/local/sbin/helpdesk-pg-backup.sh, run nightly by helpdesk-pg-backup.timer as the # postgres user. Custom-format dump of the helpdesk DB with 14-day retention. # Restore: pg_restore --no-owner -d /var/backups/helpdesk/helpdesk-.dump set -euo pipefail DIR=/var/backups/helpdesk ts=$(date +%Y%m%d-%H%M%S) umask 077 pg_dump -Fc helpdesk > "$DIR/helpdesk-$ts.dump" find "$DIR" -name 'helpdesk-*.dump' -mtime +14 -delete