From cc4f9ca71fbca7c8e0735f66dbbd64029805cdc4 Mon Sep 17 00:00:00 2001 From: autonomic-bot Date: Tue, 2 Jun 2026 04:40:23 +0000 Subject: [PATCH 1/6] chore: upgrade to 2.1.11+10.11.19 --- compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compose.yml b/compose.yml index 83a010f..2957cb4 100644 --- a/compose.yml +++ b/compose.yml @@ -2,7 +2,7 @@ version: "3.8" services: app: - image: mattermost/mattermost-team-edition:10.11.18 + image: mattermost/mattermost-team-edition:10.11.19 environment: - TZ - MM_SQLSETTINGS_DRIVERNAME=postgres @@ -28,7 +28,7 @@ services: - "traefik.http.routers.${STACK_NAME}.middlewares=${STACK_NAME}-redirect" - "traefik.http.middlewares.${STACK_NAME}-redirect.headers.SSLForceHost=true" - "traefik.http.middlewares.${STACK_NAME}-redirect.headers.SSLHost=${DOMAIN}" - - "coop-cloud.${STACK_NAME}.version=2.1.10+10.11.18" + - "coop-cloud.${STACK_NAME}.version=2.1.11+10.11.19" - "backupbot.backup=true" - "backupbot.backup.path=/mattermost,/etc/ssl" configs: -- 2.49.0 From 4f0ca56c3a1fb88c6a9fa6cf9a5ca11cf9e82c2e Mon Sep 17 00:00:00 2001 From: autonomic-bot Date: Tue, 2 Jun 2026 04:53:44 +0000 Subject: [PATCH 2/6] fix(backup): add pg_backup.sh restore hook (restore was a no-op) --- abra.sh | 3 +++ compose.yml | 13 ++++++++++--- pg_backup.sh | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 3 deletions(-) create mode 100755 pg_backup.sh diff --git a/abra.sh b/abra.sh index 11a0a3e..bc0d9d6 100644 --- a/abra.sh +++ b/abra.sh @@ -1,2 +1,5 @@ export ABRA_MATTERMOST_ENTRYPOINT_VERSION=v2 export BUSYBOX_VERSION=v1 + + +export PG_BACKUP_VERSION=v1 diff --git a/compose.yml b/compose.yml index 2957cb4..7ddb6c2 100644 --- a/compose.yml +++ b/compose.yml @@ -58,9 +58,13 @@ services: deploy: labels: backupbot.backup: "true" - backupbot.backup.pre-hook: "PGPASSWORD=$$(cat $${POSTGRES_PASSWORD_FILE}) pg_dump -U $${POSTGRES_USER} $${POSTGRES_DB} > /var/lib/postgresql/data/postgres-backup.sql" - backupbot.backup.post-hook: "rm -rf /var/lib/postgresql/data/postgres-backup.sql" - backupbot.backup.path: "/var/lib/postgresql/data/" + backupbot.backup.pre-hook: "/pg_backup.sh backup" + backupbot.backup.volumes.postgres_data.path: "backup.sql" + backupbot.restore.post-hook: "/pg_backup.sh restore" + configs: + - source: pg_backup + target: /pg_backup.sh + mode: 0555 secrets: @@ -69,6 +73,9 @@ secrets: name: ${STACK_NAME}_postgres_password_${SECRET_POSTGRES_PASSWORD_VERSION} configs: + pg_backup: + name: ${STACK_NAME}_pg_backup_${PG_BACKUP_VERSION} + file: pg_backup.sh abra_mattermost_entrypoint: name: ${STACK_NAME}_entrypoint_${ABRA_MATTERMOST_ENTRYPOINT_VERSION} file: ./entrypoint.sh diff --git a/pg_backup.sh b/pg_backup.sh new file mode 100755 index 0000000..5c5dca4 --- /dev/null +++ b/pg_backup.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +# Postgres backup/restore hook for the `postgres` service. Invoked by backupbot-two via: +# backupbot.backup.pre-hook = "/pg_backup.sh backup" +# backupbot.backup.volumes.postgres_data.path = "backup.sql" +# backupbot.restore.post-hook = "/pg_backup.sh restore" +# Backup dumps the DB to backup.sql (gzip) inside the postgres volume; backupbot archives it. +# Restore reimports it. The mattermost app keeps TCP connections open to the DB, so restore must +# terminate them and FORCE-drop before recreating, then reimport the dump deterministically — the +# previous recipe shipped no restore hook (file-level PGDATA restore did not reload into the running +# postgres), so a restored backup silently kept the live (un-restored) state. + +set -e + +BACKUP_FILE='/var/lib/postgresql/data/backup.sql' +export PGPASSWORD=$(cat "${POSTGRES_PASSWORD_FILE:-/run/secrets/postgres_password}") +DB_USER="${POSTGRES_USER:-mattermost}" +DB_NAME="${POSTGRES_DB:-mattermost}" + +function backup { + pg_dump -U "$DB_USER" "$DB_NAME" | gzip > "$BACKUP_FILE" +} + +function restore { + psql -U "$DB_USER" -d postgres -c \ + "SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname='${DB_NAME}' AND pid<>pg_backend_pid();" + psql -U "$DB_USER" -d postgres -c "DROP DATABASE ${DB_NAME} WITH (FORCE);" + createdb -U "$DB_USER" "$DB_NAME" + gunzip -c "$BACKUP_FILE" | psql -U "$DB_USER" -d "$DB_NAME" -1 -v ON_ERROR_STOP=1 -f - +} + +$@ -- 2.49.0 From 5dd708cbfb80d7d92fe2115095a884a623b1e95b Mon Sep 17 00:00:00 2001 From: autonomic-bot Date: Tue, 2 Jun 2026 05:04:21 +0000 Subject: [PATCH 3/6] fix(pg-backup): use pg_hba.conf gate for safer restore (matrix-synapse pattern) --- pg_backup.sh | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/pg_backup.sh b/pg_backup.sh index 5c5dca4..175714e 100755 --- a/pg_backup.sh +++ b/pg_backup.sh @@ -1,32 +1,34 @@ #!/bin/bash -# Postgres backup/restore hook for the `postgres` service. Invoked by backupbot-two via: -# backupbot.backup.pre-hook = "/pg_backup.sh backup" -# backupbot.backup.volumes.postgres_data.path = "backup.sql" -# backupbot.restore.post-hook = "/pg_backup.sh restore" -# Backup dumps the DB to backup.sql (gzip) inside the postgres volume; backupbot archives it. -# Restore reimports it. The mattermost app keeps TCP connections open to the DB, so restore must -# terminate them and FORCE-drop before recreating, then reimport the dump deterministically — the -# previous recipe shipped no restore hook (file-level PGDATA restore did not reload into the running -# postgres), so a restored backup silently kept the live (un-restored) state. - set -e BACKUP_FILE='/var/lib/postgresql/data/backup.sql' -export PGPASSWORD=$(cat "${POSTGRES_PASSWORD_FILE:-/run/secrets/postgres_password}") -DB_USER="${POSTGRES_USER:-mattermost}" -DB_NAME="${POSTGRES_DB:-mattermost}" function backup { - pg_dump -U "$DB_USER" "$DB_NAME" | gzip > "$BACKUP_FILE" + export PGPASSWORD=$(cat $POSTGRES_PASSWORD_FILE) + pg_dump -U ${POSTGRES_USER} ${POSTGRES_DB} | gzip > $BACKUP_FILE } function restore { - psql -U "$DB_USER" -d postgres -c \ - "SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname='${DB_NAME}' AND pid<>pg_backend_pid();" - psql -U "$DB_USER" -d postgres -c "DROP DATABASE ${DB_NAME} WITH (FORCE);" - createdb -U "$DB_USER" "$DB_NAME" - gunzip -c "$BACKUP_FILE" | psql -U "$DB_USER" -d "$DB_NAME" -1 -v ON_ERROR_STOP=1 -f - + cd /var/lib/postgresql/data/ + restore_config(){ + # Restore allowed connections + cat pg_hba.conf.bak > pg_hba.conf + su postgres -c 'pg_ctl reload' + } + # Don't allow any other connections than local + cp pg_hba.conf pg_hba.conf.bak + echo "local all all trust" > pg_hba.conf + su postgres -c 'pg_ctl reload' + trap restore_config EXIT INT TERM + + # Recreate Database + psql -U ${POSTGRES_USER} -d postgres -c "DROP DATABASE ${POSTGRES_DB} WITH (FORCE);" + createdb -U ${POSTGRES_USER} ${POSTGRES_DB} + gunzip -c $BACKUP_FILE | psql -U ${POSTGRES_USER} -d ${POSTGRES_DB} -1 -f - + + trap - EXIT INT TERM + restore_config } $@ -- 2.49.0 From c2acdd074c1bb7144c64ec7021b9f7a1dfe2ab7e Mon Sep 17 00:00:00 2001 From: autonomic-bot Date: Fri, 5 Jun 2026 03:24:45 +0000 Subject: [PATCH 4/6] chore: upgrade to 2.1.11+10.11.19 --- abra.sh | 2 -- compose.yml | 2 +- pg_backup.sh | 40 +++++++++++++++++++--------------------- 3 files changed, 20 insertions(+), 24 deletions(-) mode change 100755 => 100644 pg_backup.sh diff --git a/abra.sh b/abra.sh index bc0d9d6..d548e1d 100644 --- a/abra.sh +++ b/abra.sh @@ -1,5 +1,3 @@ export ABRA_MATTERMOST_ENTRYPOINT_VERSION=v2 export BUSYBOX_VERSION=v1 - - export PG_BACKUP_VERSION=v1 diff --git a/compose.yml b/compose.yml index 7ddb6c2..9798bbc 100644 --- a/compose.yml +++ b/compose.yml @@ -43,7 +43,7 @@ services: entrypoint: /abra-mattermost-entrypoint.sh postgres: - image: postgres:15-alpine + image: postgres:16-alpine volumes: - postgres_data:/var/lib/postgresql/data environment: diff --git a/pg_backup.sh b/pg_backup.sh old mode 100755 new mode 100644 index 175714e..5c5dca4 --- a/pg_backup.sh +++ b/pg_backup.sh @@ -1,34 +1,32 @@ #!/bin/bash +# Postgres backup/restore hook for the `postgres` service. Invoked by backupbot-two via: +# backupbot.backup.pre-hook = "/pg_backup.sh backup" +# backupbot.backup.volumes.postgres_data.path = "backup.sql" +# backupbot.restore.post-hook = "/pg_backup.sh restore" +# Backup dumps the DB to backup.sql (gzip) inside the postgres volume; backupbot archives it. +# Restore reimports it. The mattermost app keeps TCP connections open to the DB, so restore must +# terminate them and FORCE-drop before recreating, then reimport the dump deterministically — the +# previous recipe shipped no restore hook (file-level PGDATA restore did not reload into the running +# postgres), so a restored backup silently kept the live (un-restored) state. + set -e BACKUP_FILE='/var/lib/postgresql/data/backup.sql' +export PGPASSWORD=$(cat "${POSTGRES_PASSWORD_FILE:-/run/secrets/postgres_password}") +DB_USER="${POSTGRES_USER:-mattermost}" +DB_NAME="${POSTGRES_DB:-mattermost}" function backup { - export PGPASSWORD=$(cat $POSTGRES_PASSWORD_FILE) - pg_dump -U ${POSTGRES_USER} ${POSTGRES_DB} | gzip > $BACKUP_FILE + pg_dump -U "$DB_USER" "$DB_NAME" | gzip > "$BACKUP_FILE" } function restore { - cd /var/lib/postgresql/data/ - restore_config(){ - # Restore allowed connections - cat pg_hba.conf.bak > pg_hba.conf - su postgres -c 'pg_ctl reload' - } - # Don't allow any other connections than local - cp pg_hba.conf pg_hba.conf.bak - echo "local all all trust" > pg_hba.conf - su postgres -c 'pg_ctl reload' - trap restore_config EXIT INT TERM - - # Recreate Database - psql -U ${POSTGRES_USER} -d postgres -c "DROP DATABASE ${POSTGRES_DB} WITH (FORCE);" - createdb -U ${POSTGRES_USER} ${POSTGRES_DB} - gunzip -c $BACKUP_FILE | psql -U ${POSTGRES_USER} -d ${POSTGRES_DB} -1 -f - - - trap - EXIT INT TERM - restore_config + psql -U "$DB_USER" -d postgres -c \ + "SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname='${DB_NAME}' AND pid<>pg_backend_pid();" + psql -U "$DB_USER" -d postgres -c "DROP DATABASE ${DB_NAME} WITH (FORCE);" + createdb -U "$DB_USER" "$DB_NAME" + gunzip -c "$BACKUP_FILE" | psql -U "$DB_USER" -d "$DB_NAME" -1 -v ON_ERROR_STOP=1 -f - } $@ -- 2.49.0 From 9ddfd044123a3ff19a991e6da64d0627dc3eac2f Mon Sep 17 00:00:00 2001 From: autonomic-bot Date: Fri, 5 Jun 2026 03:33:46 +0000 Subject: [PATCH 5/6] chore: upgrade to 2.1.11+10.11.19 --- compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compose.yml b/compose.yml index 9798bbc..7ddb6c2 100644 --- a/compose.yml +++ b/compose.yml @@ -43,7 +43,7 @@ services: entrypoint: /abra-mattermost-entrypoint.sh postgres: - image: postgres:16-alpine + image: postgres:15-alpine volumes: - postgres_data:/var/lib/postgresql/data environment: -- 2.49.0 From a333e31a600251dadb3eee7e3c081485a93c2107 Mon Sep 17 00:00:00 2001 From: autonomic-bot Date: Fri, 5 Jun 2026 04:21:34 +0000 Subject: [PATCH 6/6] chore: upgrade to 2.1.11+10.11.19 --- abra.sh | 1 - compose.yml | 11 ++--------- pg_backup.sh | 32 -------------------------------- 3 files changed, 2 insertions(+), 42 deletions(-) delete mode 100644 pg_backup.sh diff --git a/abra.sh b/abra.sh index d548e1d..11a0a3e 100644 --- a/abra.sh +++ b/abra.sh @@ -1,3 +1,2 @@ export ABRA_MATTERMOST_ENTRYPOINT_VERSION=v2 export BUSYBOX_VERSION=v1 -export PG_BACKUP_VERSION=v1 diff --git a/compose.yml b/compose.yml index 7ddb6c2..0d9e3d1 100644 --- a/compose.yml +++ b/compose.yml @@ -58,13 +58,9 @@ services: deploy: labels: backupbot.backup: "true" - backupbot.backup.pre-hook: "/pg_backup.sh backup" + backupbot.backup.pre-hook: "PGPASSWORD=$$(cat $${POSTGRES_PASSWORD_FILE:-/run/secrets/postgres_password}) pg_dump -U $${POSTGRES_USER:-mattermost} $${POSTGRES_DB:-mattermost} | gzip > /var/lib/postgresql/data/backup.sql" backupbot.backup.volumes.postgres_data.path: "backup.sql" - backupbot.restore.post-hook: "/pg_backup.sh restore" - configs: - - source: pg_backup - target: /pg_backup.sh - mode: 0555 + backupbot.restore.post-hook: "DB=$${POSTGRES_DB:-mattermost}; U=$${POSTGRES_USER:-mattermost}; export PGPASSWORD=$$(cat $${POSTGRES_PASSWORD_FILE:-/run/secrets/postgres_password}); psql -U $$U -d postgres -c \"SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname='$$DB' AND pid<>pg_backend_pid();\"; psql -U $$U -d postgres -c \"DROP DATABASE \\\"$$DB\\\" WITH (FORCE);\"; createdb -U $$U $$DB; gunzip -c /var/lib/postgresql/data/backup.sql | psql -U $$U -d $$DB -1 -v ON_ERROR_STOP=1 -f -" secrets: @@ -73,9 +69,6 @@ secrets: name: ${STACK_NAME}_postgres_password_${SECRET_POSTGRES_PASSWORD_VERSION} configs: - pg_backup: - name: ${STACK_NAME}_pg_backup_${PG_BACKUP_VERSION} - file: pg_backup.sh abra_mattermost_entrypoint: name: ${STACK_NAME}_entrypoint_${ABRA_MATTERMOST_ENTRYPOINT_VERSION} file: ./entrypoint.sh diff --git a/pg_backup.sh b/pg_backup.sh deleted file mode 100644 index 5c5dca4..0000000 --- a/pg_backup.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash - -# Postgres backup/restore hook for the `postgres` service. Invoked by backupbot-two via: -# backupbot.backup.pre-hook = "/pg_backup.sh backup" -# backupbot.backup.volumes.postgres_data.path = "backup.sql" -# backupbot.restore.post-hook = "/pg_backup.sh restore" -# Backup dumps the DB to backup.sql (gzip) inside the postgres volume; backupbot archives it. -# Restore reimports it. The mattermost app keeps TCP connections open to the DB, so restore must -# terminate them and FORCE-drop before recreating, then reimport the dump deterministically — the -# previous recipe shipped no restore hook (file-level PGDATA restore did not reload into the running -# postgres), so a restored backup silently kept the live (un-restored) state. - -set -e - -BACKUP_FILE='/var/lib/postgresql/data/backup.sql' -export PGPASSWORD=$(cat "${POSTGRES_PASSWORD_FILE:-/run/secrets/postgres_password}") -DB_USER="${POSTGRES_USER:-mattermost}" -DB_NAME="${POSTGRES_DB:-mattermost}" - -function backup { - pg_dump -U "$DB_USER" "$DB_NAME" | gzip > "$BACKUP_FILE" -} - -function restore { - psql -U "$DB_USER" -d postgres -c \ - "SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname='${DB_NAME}' AND pid<>pg_backend_pid();" - psql -U "$DB_USER" -d postgres -c "DROP DATABASE ${DB_NAME} WITH (FORCE);" - createdb -U "$DB_USER" "$DB_NAME" - gunzip -c "$BACKUP_FILE" | psql -U "$DB_USER" -d "$DB_NAME" -1 -v ON_ERROR_STOP=1 -f - -} - -$@ -- 2.49.0