aboutsummaryrefslogblamecommitdiff
path: root/app/backup/build/backup-matrix/do_backup.sh
blob: 74cd9dadc578f9542e60224ed07cb6c8cf518e86 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
















                                                       
                                  
                                                                              




                                                                                         
                               

                                                                                            
#!/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
pg_dump -v -Fc -U $MATRIX_PSQL_USER -h 192.168.0.2 -p 5433 $MATRIX_PSQL_DB | \
	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"
tar -vzcf - ${MATRIX_MEDIA} | \
	age -r "$(cat /root/.ssh/id_ed25519.pub)" | \
	ssh backuphost "cat > $TARGET_SSH_DIR/matrix/media-$(date --iso-8601=minute).gz.age"