#!/usr/bin/env bash DB_FILENAME="/home/mastodon/db-backup-$(date '+%Y-%m-%d').sql" if ! pg_dump -U mastodon mastodon_production -p 5432 -f "$DB_FILENAME"; then echo "Error creating backup of mastodon_production database" exit 1 else echo "Backup of mastodon_production database completed" fi find /home/mastodon \ -maxdepth 1 \ -type f \ \( -name "*.sql" -and -not -wholename "$DB_FILENAME" \) \ -delete exit 0