Skip to content

Instantly share code, notes, and snippets.

View andrelop's full-sized avatar

André Luís Lopes andrelop

View GitHub Profile
@andrelop
andrelop / gist:941be7f182c11a4a3204f6a9031258a2
Last active May 1, 2024 21:42
Example backup script for Mastodon, WriteFreely and Miniflux
#!/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'