Synapse: Added backup script

This commit is contained in:
Viyurz 2023-11-29 13:50:53 +00:00
parent 6f6a12640e
commit 20e20fe290
No known key found for this signature in database
2 changed files with 45 additions and 1 deletions

24
synapse/backup.sh Executable file
View file

@ -0,0 +1,24 @@
#!/bin/bash
if [[ $UID -ne 0 ]]; then
echo "Must be run as root."
exit 1
fi
media_dir="/mnt/synapsedata/media_store"
backup_date="$(date '+%Y%m%d-%Hh%Mm')"
bak_folder="/mnt/backups/synapsebackup"
borg_repo="$bak_folder/borg"
mkdir -p "$bak_folder"
# PSQL
echo "Creating backup of PosgreSQL databases to $bak_folder/dump_$backup_date.sql"
docker exec -t synapse_postgres pg_dumpall -c -U synapse > "$bak_folder/dump_$backup_date.sql"
echo "Done, total size of all backups: $(du -hc $bak_folder/dump_* | grep total | grep -oP '^[\d\w]+')."
# Media
[[ -d "$borg_repo" ]] || borg init --encryption=none "$borg_repo"
borg create --stats "$borg_repo::media-{now:%Y-%m-%d_%H:%M:%S}" "$media_dir"
borg prune --stats --keep-daily=7 --keep-weekly=4 --keep-monthly=3 "$borg_repo"
borg compact "$borg_repo"

View file

@ -38,6 +38,26 @@ form_secret: "bj5sv.-B:R.2Z@@cK*rBti&J,v^34.gXNNR*5tNPWTUpkrE+Sv"
signing_key_path: "/data/viyurz.fr.signing.key" signing_key_path: "/data/viyurz.fr.signing.key"
trusted_key_servers: trusted_key_servers:
- server_name: "matrix.org" - server_name: "matrix.org"
url_preview_enabled: true
url_preview_ip_range_blacklist:
- '127.0.0.0/8'
- '10.0.0.0/8'
- '172.16.0.0/12'
- '192.168.0.0/16'
- '100.64.0.0/10'
- '192.0.0.0/24'
- '169.254.0.0/16'
- '192.88.99.0/24'
- '198.18.0.0/15'
- '192.0.2.0/24'
- '198.51.100.0/24'
- '203.0.113.0/24'
- '224.0.0.0/4'
- '::1/128'
- 'fe80::/10'
- 'fc00::/7'
- '2001:db8::/32'
- 'ff00::/8'
- 'fec0::/10'
# vim:ft=yaml # vim:ft=yaml