-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathlocal-backup
More file actions
executable file
·18 lines (13 loc) · 877 Bytes
/
local-backup
File metadata and controls
executable file
·18 lines (13 loc) · 877 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/bash
set -o errexit -o nounset -o pipefail
remote=flarum-admin@discuss.grapheneos.org
timestamp=$(date -u +%Y-%m-%dT%H:%M:%SZ)
ssh $remote "rm -rf local-backup"
ssh $remote "mkdir local-backup"
ssh $remote "mkdir local-backup/$timestamp"
ssh $remote "mariadb-dump --all-databases --single-transaction > local-backup/$timestamp/all_databases.sql"
ssh $remote "cp /var/lib/valkey/dump.rdb local-backup/$timestamp/"
ssh $remote "rsync -rl --exclude '/storage/cache/*' --exclude '/storage/gdpr-exports/*' --exclude '/storage/sessions/*' --exclude '/storage/tmp/*' /opt/flarum/ local-backup/$timestamp/flarum"
ssh $remote "tar -cC local-backup $timestamp | zstd -9 --long | age -r \$(cat backup-public-key.txt) -o local-backup/$timestamp.tar.zst.age"
rsync -v --fsync --preallocate $remote:./local-backup/$timestamp.tar.zst.age backup/
ssh $remote "rm -rf local-backup"