mirror of
https://github.com/GrapheneOS/matrix.grapheneos.org.git
synced 2024-12-23 14:39:31 -05:00
add backup scripts and systemd units
This commit is contained in:
parent
989ed9718c
commit
7054e7c09f
15
local-backup
Executable file
15
local-backup
Executable file
@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -o errexit -o nounset -o pipefail
|
||||||
|
|
||||||
|
remote=root@matrix.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 "pg_dumpall -U postgres > local-backup/$timestamp/all_databases.sql"
|
||||||
|
ssh $remote "cp -a /etc/synapse local-backup/$timestamp/synapse"
|
||||||
|
ssh $remote "tar c -C local-backup $timestamp | zstd -9 | age -r \$(cat backup-public-key.txt) -o local-backup/$timestamp.tar.zst.age"
|
||||||
|
rsync -v $remote:./local-backup/$timestamp.tar.zst.age backup/
|
13
remote-backup
Executable file
13
remote-backup
Executable file
@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -o errexit -o nounset -o pipefail
|
||||||
|
|
||||||
|
timestamp=$(date -u +%Y-%m-%dT%H:%m:%SZ)
|
||||||
|
rm -rf remote-backup
|
||||||
|
mkdir remote-backup
|
||||||
|
|
||||||
|
mkdir remote-backup/$timestamp
|
||||||
|
pg_dumpall -U postgres > remote-backup/$timestamp/all_databases.sql
|
||||||
|
cp -a /etc/synapse remote-backup/$timestamp/synapse
|
||||||
|
tar c remote-backup/$timestamp | zstd -9 | age -r $(cat backup-public-key.txt) -o remote-backup/$timestamp.tar.zst.age
|
||||||
|
sshpass -f cloud-archive-password.txt rsync -v ./remote-backup/$timestamp.tar.zst.age pca@gateways.storage.gra.cloud.ovh.net:backup/
|
8
remote-backup.service
Normal file
8
remote-backup.service
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Perform remote backup
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStart=/usr/local/bin/remote-backup
|
||||||
|
Type=oneshot
|
||||||
|
User=root
|
||||||
|
WorkingDirectory=/root
|
8
remote-backup.timer
Normal file
8
remote-backup.timer
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Perform remote backup backups daily
|
||||||
|
|
||||||
|
[Timer]
|
||||||
|
OnCalendar=daily
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=timers.target
|
Loading…
Reference in New Issue
Block a user