This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
TODAY=$(date +%Y%m%d) | |
YESTERDAY=$(date --date '1 day ago' +%Y%m%d) | |
# Backup Mastodon database | |
MASTODON_DB_CONTAINER=$(docker ps | grep mastodon_postgresql | awk '{print $1}') | |
docker exec -it ${MASTODON_DB_CONTAINER} bash -c 'rm -rf /var/lib/postgresql/data/'${YESTERDAY}' || true ; mkdir /var/lib/postgresql/data/'${TODAY}' || true' | |
docker exec -it ${MASTODON_DB_CONTAINER} bash -c 'pg_dumpall -c -U mastodon > /var/lib/postgresql/data/'${TODAY}'/mastodon-dump.sql' |