Try to migrate to pg_basebackup

This commit is contained in:
Quentin 2021-04-17 12:21:13 +02:00
parent 3135c38505
commit 338a8ec7da
Signed by: quentin
GPG key ID: A98E9B769E4FF428
3 changed files with 20 additions and 8 deletions

View file

@ -14,9 +14,22 @@ Host backuphost
EOF EOF
echo "export sql" echo "export sql"
# note, -Fc means that postgresql compresses the output export PGPASSWORD=$REPL_PSQL_PWD
export PGPASSWORD=$MATRIX_PSQL_PWD pg_basebackup \
pg_dump -v -Fc -U $MATRIX_PSQL_USER -h 192.168.0.2 -p 5433 $MATRIX_PSQL_DB | \ --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)" | \ age -r "$(cat /root/.ssh/id_ed25519.pub)" | \
ssh backuphost "cat > $TARGET_SSH_DIR/matrix/db-$(date --iso-8601=minute).gz.age" ssh backuphost "cat > $TARGET_SSH_DIR/matrix/db-$(date --iso-8601=minute).gz.age"

View file

@ -7,7 +7,7 @@ job "backup_manual_matrix" {
driver = "docker" driver = "docker"
config { config {
image = "superboum/backup_matrix:3" image = "superboum/backup_matrix:4"
volumes = [ volumes = [
"secrets/id_ed25519:/root/.ssh/id_ed25519", "secrets/id_ed25519:/root/.ssh/id_ed25519",
"secrets/id_ed25519.pub:/root/.ssh/id_ed25519.pub", "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_PORT={{ key "secrets/backup/target_ssh_port" }}
TARGET_SSH_HOST={{ key "secrets/backup/target_ssh_host" }} TARGET_SSH_HOST={{ key "secrets/backup/target_ssh_host" }}
TARGET_SSH_DIR={{ key "secrets/backup/target_ssh_dir" }} TARGET_SSH_DIR={{ key "secrets/backup/target_ssh_dir" }}
MATRIX_PSQL_DB={{ key "secrets/chat/synapse/postgres_db" }} REPL_PSQL_USER={{ key "secrets/postgres/keeper/pg_repl_username" }}
MATRIX_PSQL_USER={{ key "secrets/chat/synapse/postgres_user" }} REPL_PSQL_PWD={{ key "secrets/postgres/keeper/pg_repl_pwd" }}
MATRIX_PSQL_PWD={{ key "secrets/chat/synapse/postgres_pwd" }}
EOH EOH
destination = "secrets/env_vars" destination = "secrets/env_vars"

View file

@ -108,4 +108,4 @@ services:
backup-matrix: backup-matrix:
build: build:
context: ./backup/build/backup-matrix context: ./backup/build/backup-matrix
image: superboum/backup_matrix:3 image: superboum/backup_matrix:4