admin-scripts/bin/mastodon-db-backup
Jeffrey Serio b8246306d3 Reorganize
2024-06-23 08:10:36 -05:00

19 lines
444 B
Bash
Executable File

#!/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