My #GoToSocial backup procedure:
This runs as a cron job every day at an off-peak hour. Do bear in mind that both the sqlite backup, which takes place while GTS is running and therefore must handle locks, and xz, take up a lot of CPU power.
#!/bin/bash
umask 027
now0="$(date +'%F %T')"
printf "%s: Starting backup.\n" "$now0"
cd /home/gts/gts || { printf "Impossible to backup. Cannot access directory.\n"; exit; }
mv --backup=numbered instance.back.tar.xz db-backups
printf "Backing up database.\n"
sqlite3 sqlite.db ".backup 'sqlite.db.back'"
printf "Preparing file list.\n"
echo sqlite.db.back > file.list
echo config.yaml >> file.list
echo db-backup.sh >> file.list
echo file.list >> file.list
./gotosocial --config-path config.yaml admin media list-attachments --local-only >> file.list
./gotosocial --config-path config.yaml admin media list-emojis --local-only >> file.list
printf "Tarring up instance data.\n"
tar -cf instance.back.tar -T file.list
printf "Removing auxiliary files.\n"
rm sqlite.db.back file.list
xz -T3 -e --best instance.back.tar
now="$(date +'%F %T')"
printf "%s: Finished backing up.\n" "$now"
modulux
in reply to modulux • • •