Skip to content

Instantly share code, notes, and snippets.



Created Jul 6, 2020
What would you like to do?'s backup script
# Welcome to's backup script!
# === Config
bucketname=[something here]
# === Preping
mkdir -p /tmp/backups/mastodon
mkdir -p /tmp/backups/pleroma
chmod 777 /tmp/backups/*
set -e
# ==== Pleroma
echo "[Pleroma] => Dumping DB"
su - postgres -c "pg_dump -Fc pleroma_prod -f /tmp/backups/pleroma/pleroma_prod.dump"
echo "[Pleroma] => Copying config.exs"
cp /etc/pleroma/config.exs /tmp/backups/pleroma/config.exs
# ==== Mastodon
echo "[Mastodon] => Dumping DB"
su - mastodon -c "pg_dump -Fc mastodon_production -f /tmp/backups/mastodon/mastodon_production.dump"
echo "[Mastodon] => Copying .env.production and Redis DB"
cp /home/mastodon/live/.env.production /tmp/backups/mastodon/.env.production
cp /var/lib/redis/dump.rdb /tmp/backups/mastodon/dump.rdb
# ==== Sync
echo "[Sync] => Syncing DBs and configs"
b2 sync --keepDays 7 --replaceNewer /tmp/backups/ b2://$bucketname/backups/
echo "[Sync] => Syncing Pleroma uploads"
b2 sync --delete --compareVersions none /var/lib/pleroma/uploads/ b2://$bucketname/data/pleroma/uploads/
echo "[Sync] => Syncing Mastodon uploads"
b2 sync --delete --compareVersions none --excludeDirRegex '.*preview_cards' --excludeDirRegex '.*cache' /opt/system/ b2://$bucketname/data/mastodon/system/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.