admin-scripts/bin/mastodon-db-backup

19 lines
444 B
Plaintext
Raw Normal View History

2024-06-20 17:12:41 +02:00
#!/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