In order to comply with the Mastodon Server Covenant, we want to setup daily backups for our non-Docker Mastodon instance (currently we have automatic weekly backups for the entire server). Post-installation steps - Mastodon documentation explains what needs backup but requires to know what you’re doing. Do you know about a step by step guide or… how have you solved this problem?
I wrote this tiny script called each day by the crontab of root, it keeps 7 days of backup :
#!/bin/sh TAR="$(which tar)" GZIP="$(which gzip)" SAUVEGARDE=/root/SAUVEGARDES-MASTODON MASTODON=/home/mastodon/live AUJOURDHUI=$(date +%F) cd /tmp sudo -n -u postgres pg_dump mastodon_production > /tmp/dump_mastodon_$AUJOURDHUI.sql mkdir $SAUVEGARDE/$AUJOURDHUI mv /tmp/dump_mastodon_$AUJOURDHUI.sql $SAUVEGARDE/$AUJOURDHUI/dump.sql cd $SAUVEGARDE/$AUJOURDHUI cp /var/lib/redis/dump.rdb $SAUVEGARDE/$AUJOURDHUI $TAR -vzcf $SAUVEGARDE/$AUJOURDHUI/SauvegardeMastodon_$AUJOURDHUI.tgz $SAUVEGARDE/$AUJOURDHUI/dump.* $MASTODON/.env.production && rm -f $SAUVEGARDE/$AUJOURDHUI/dump.* chmod -R 400 $SAUVEGARDE/$AUJOURDHUI ls -lh $SAUVEGARDE/$AUJOURDHUI cd $SAUVEGARDE find $SAUVEGARDE/* -type d -ctime +6 | xargs rm -rf tree -hrcDup $SAUVEGARDE df -ht ext4
Any suggestions for improvement are welcome!
I think to need three kind of backups at least which are postgres, redis, and .env.production. Optionally, need to icons, headers, and media attachments too.
This is my scripts
Is there any way i can send backup to Google drive? I got unlimited account and it will save me some buck
@vibhigupta hmm…sorry, I don’t have the knowledge to work with google drive.
I backing up these datas as secondary backups to my home server with rsync over ssh.