admin-scripts/bin/mastodon-to-minio
2024-06-25 04:29:00 -05:00

34 lines
928 B
Bash
Executable File

#!/usr/bin/env bash
DB_FILENAME="/home/mastodon/db-backup-$(date '+%Y-%m-%d').sql"
if ! pg_dump -U mastodon -Fc 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
if ! rclone copy --transfers=4 /home/mastodon/live/public/system minio:mastodata; then
echo "Error rcloning /home/mastodon/live/public/system to MinIO instance"
exit 1
fi
if ! rclone copy "${DB_FILENAME}" minio:mastodata; then
echo "Error rcloning ${DB_FILENAME} to MinIO instance"
exit 1
fi
if ! rclone copy /home/mastodon/live/.env.production minio:mastodata; then
echo "Error rcloning /home/mastodon/live/.env.production to MinIO instance"
exit 1
fi
exit 0