This repository has been archived on 2023-03-15. You can view files and clone it, but cannot push or open issues or pull requests.
infrastructure/app/backup/build/backup-matrix/do_backup.sh

28 lines
746 B
Bash
Raw Normal View History

2021-03-06 18:52:13 +00:00
#!/bin/sh
set -x -e
cd /root
chmod 0600 .ssh/id_ed25519
cat > .ssh/config <<EOF
Host backuphost
HostName $TARGET_SSH_HOST
Port $TARGET_SSH_PORT
User $TARGET_SSH_USER
EOF
echo "export sql"
# note, -Fc means that postgresql compresses the output
export PGPASSWORD=$MATRIX_PSQL_PWD
2021-04-15 10:38:31 +00:00
pg_dump -v -Fc -U $MATRIX_PSQL_USER -h 192.168.0.2 -p 5433 $MATRIX_PSQL_DB | \
2021-03-06 18:52:13 +00:00
age -r "$(cat /root/.ssh/id_ed25519.pub)" | \
ssh backuphost "cat > $TARGET_SSH_DIR/matrix/db-$(date --iso-8601=minute).gz.age"
MATRIX_MEDIA="/mnt/glusterfs/chat/matrix/synapse/media"
echo "export local_content"
2021-03-06 20:43:55 +00:00
tar -vzcf - ${MATRIX_MEDIA} | \
2021-03-06 18:52:13 +00:00
age -r "$(cat /root/.ssh/id_ed25519.pub)" | \
ssh backuphost "cat > $TARGET_SSH_DIR/matrix/media-$(date --iso-8601=minute).gz.age"