From 338a8ec7da79ecaccb70f2fbd7cecd385a32fae7 Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Sat, 17 Apr 2021 12:21:13 +0200 Subject: Try to migrate to pg_basebackup --- app/backup/build/backup-matrix/do_backup.sh | 19 ++++++++++++++++--- app/backup/deploy/backup-matrix.hcl | 7 +++---- 2 files changed, 19 insertions(+), 7 deletions(-) (limited to 'app/backup') diff --git a/app/backup/build/backup-matrix/do_backup.sh b/app/backup/build/backup-matrix/do_backup.sh index 74cd9da..7461409 100755 --- a/app/backup/build/backup-matrix/do_backup.sh +++ b/app/backup/build/backup-matrix/do_backup.sh @@ -14,9 +14,22 @@ Host backuphost 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 | \ +export PGPASSWORD=$REPL_PSQL_PWD +pg_basebackup \ + --pgdata=- \ + --format=tar \ + --max-rate=1M \ + --no-slot \ + --wal-method=none \ + --gzip \ + --compress=8 \ + --checkpoint=spread \ + --progress \ + --verbose \ + --status-interval=10 \ + --username=$REPL_PSQL_USER \ + --port=5432 \ + --host=psql-proxy.service.2.cluster.deuxfleurs.fr | \ age -r "$(cat /root/.ssh/id_ed25519.pub)" | \ ssh backuphost "cat > $TARGET_SSH_DIR/matrix/db-$(date --iso-8601=minute).gz.age" diff --git a/app/backup/deploy/backup-matrix.hcl b/app/backup/deploy/backup-matrix.hcl index 1c85e38..cb28c90 100644 --- a/app/backup/deploy/backup-matrix.hcl +++ b/app/backup/deploy/backup-matrix.hcl @@ -7,7 +7,7 @@ job "backup_manual_matrix" { driver = "docker" config { - image = "superboum/backup_matrix:3" + image = "superboum/backup_matrix:4" volumes = [ "secrets/id_ed25519:/root/.ssh/id_ed25519", "secrets/id_ed25519.pub:/root/.ssh/id_ed25519.pub", @@ -27,9 +27,8 @@ TARGET_SSH_USER={{ key "secrets/backup/target_ssh_user" }} TARGET_SSH_PORT={{ key "secrets/backup/target_ssh_port" }} TARGET_SSH_HOST={{ key "secrets/backup/target_ssh_host" }} TARGET_SSH_DIR={{ key "secrets/backup/target_ssh_dir" }} -MATRIX_PSQL_DB={{ key "secrets/chat/synapse/postgres_db" }} -MATRIX_PSQL_USER={{ key "secrets/chat/synapse/postgres_user" }} -MATRIX_PSQL_PWD={{ key "secrets/chat/synapse/postgres_pwd" }} +REPL_PSQL_USER={{ key "secrets/postgres/keeper/pg_repl_username" }} +REPL_PSQL_PWD={{ key "secrets/postgres/keeper/pg_repl_pwd" }} EOH destination = "secrets/env_vars" -- cgit v1.2.3