8 Commits

Author SHA1 Message Date
b6b52b6e9c chore: publish 2.1.0+6.5.0-34 release
All checks were successful
continuous-integration/drone/tag Build is passing
2025-05-27 16:25:24 +02:00
d7dbf76a53 fix saml logout url 2025-01-21 16:10:01 +01:00
f80f630304 Update .drone.yml 2025-01-08 10:09:13 -08:00
73e9f7bfcc chore: publish 2.0.0+6.4.0-34 release
All checks were successful
continuous-integration/drone/tag Build is passing
2024-12-03 18:34:35 +01:00
3a940d845f update pg_backup.sh 2024-10-22 21:33:15 +02:00
d7b3c1e18e add ENABLE_BACKUPS label 2024-10-22 17:28:22 +02:00
3af308645e chore: publish 1.0.5+6.3.1-95 release
All checks were successful
continuous-integration/drone/tag Build is passing
2024-10-15 19:06:10 +02:00
cb85124b06 Add postgres backup script pg_backup 2024-10-15 17:25:01 +02:00
6 changed files with 61 additions and 19 deletions

View File

@ -32,7 +32,7 @@ steps:
from_secret: drone_abra-bot_token
fork: true
repositories:
- coop-cloud/auto-recipes-catalogue-json
- toolshed/auto-recipes-catalogue-json
trigger:
event: tag

View File

@ -2,6 +2,7 @@ TYPE=zammad
DOMAIN=zammad.example.com
TIMEOUT=600
ENABLE_BACKUPS=true
## Domain aliases
#EXTRA_DOMAINS=', `www.zammad.example.com`'
@ -28,7 +29,7 @@ SMTP_PORT=465
## SAML SSO ##
#SSO_PROVIDER_DOMAIN=authentik.example.com
#IDP_SSO_TARGET_URL=https://authentik.example.com/application/saml/zammad/sso/binding/init/
#IDP_SLO_SERVICE_URL=https://authentik.example.com/application/saml/zammad/slo/binding/redirect/
#IDP_SLO_SERVICE_URL=https://zammad.example.com/auth/saml/slo
## Zammad internal backups

View File

@ -1,5 +1,6 @@
export ENTRYPOINT_VERSION=v2
export AUTO_WIZARD_VERSION=v2
export PG_BACKUP_VERSION=v2
get_setting_changes() {
/custom-entrypoint.sh "rails r 'puts JSON.pretty_generate(JSON.parse(Setting.all.select{ |setting| setting.state_current != setting.state_initial }.map { |setting| {name: setting.name, value: setting.state_current[\""value\""]} } .to_json))'"

View File

@ -1,7 +1,7 @@
version: "3.8"
services:
zammad-backup:
image: ghcr.io/zammad/zammad:6.3.1-95
image: ghcr.io/zammad/zammad:6.5.0-34
command: ["zammad-backup"]
volumes:
- zammad-backup:/var/tmp/zammad

View File

@ -43,7 +43,7 @@ x-shared:
SSO_PROVIDER_DOMAIN:
IDP_SSO_TARGET_URL:
IDP_SLO_SERVICE_URL:
image: ghcr.io/zammad/zammad:6.3.1-95
image: ghcr.io/zammad/zammad:6.5.0-34
deploy:
restart_policy:
condition: on-failure
@ -55,11 +55,11 @@ x-shared:
- zammad-redis
entrypoint: /custom-entrypoint.sh
configs:
- source: entrypoint
target: /custom-entrypoint.sh
mode: 0555
- source: auto_wizard
target: /opt/zammad/contrib/auto_wizard.json
- source: entrypoint
target: /custom-entrypoint.sh
mode: 0555
- source: auto_wizard
target: /opt/zammad/contrib/auto_wizard.json
secrets:
- db_password
- smtp_password
@ -67,7 +67,7 @@ x-shared:
services:
zammad-elasticsearch:
image: bitnami/elasticsearch:8.14.3
image: bitnami/elasticsearch:8.18.0
deploy:
restart_policy:
condition: on-failure
@ -86,7 +86,7 @@ services:
timeout: 10s
retries: 10
start_period: 5m
zammad-init:
<<: *zammad-service
command: ["zammad-init"]
@ -96,7 +96,7 @@ services:
zammad-memcached:
command: memcached -m 256M
image: memcached:1.6.29-alpine
image: memcached:1.6.38-alpine
healthcheck:
test: 'echo "version" | nc -vn -w 1 127.0.0.1 11211'
interval: 30s
@ -130,7 +130,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=1.0.4+6.3.1-95"
- "coop-cloud.${STACK_NAME}.version=2.1.0+6.5.0-34"
- "coop-cloud.${STACK_NAME}.timeout=${TIMEOUT:-120}"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080"]
@ -149,14 +149,18 @@ services:
restart_policy:
condition: on-failure
labels:
backupbot.backup: "true"
backupbot.backup.pre-hook: "PGPASSWORD=$$(cat /run/secrets/db_password) pg_dump -U $${POSTGRES_USER} $${POSTGRES_DB} > /var/lib/postgresql/data/backup.sql"
backupbot.backup: "${ENABLE_BACKUPS:-true}"
backupbot.backup.pre-hook: "/pg_backup.sh backup"
backupbot.backup.volumes.postgresql-data.path: "backup.sql"
backupbot.restore.post-hook: 'psql -U $${POSTGRES_USER} -d postgres -c "DROP DATABASE $${POSTGRES_DB} WITH (FORCE);" && createdb -U $${POSTGRES_USER} $${POSTGRES_DB} && psql -U $${POSTGRES_USER} -d $${POSTGRES_DB} -f /var/lib/postgresql/data/backup.sql'
backupbot.restore.post-hook: "/pg_backup.sh restore"
backupbot.backup.volumes.elasticsearch-data: "false"
backupbot.backup.volumes.redis-data: "false"
volumes:
- postgresql-data:/var/lib/postgresql/data
configs:
- source: pg_backup
target: /pg_backup.sh
mode: 0555
secrets:
- db_password
healthcheck:
@ -176,9 +180,8 @@ services:
retries: 10
start_period: 5m
zammad-redis:
image: redis:7.2.5-alpine
image: redis:7.4.3-alpine
deploy:
restart_policy:
condition: on-failure
@ -195,7 +198,7 @@ services:
<<: *zammad-service
command: ["zammad-scheduler"]
healthcheck:
test: 'ps x | grep "[b]ackground-worker.rb"'
test: 'grep -a "background-worker.rb" -r /proc/[0-9]*/cmdline'
interval: 30s
timeout: 10s
retries: 10
@ -230,6 +233,9 @@ configs:
name: ${STACK_NAME}_auto_wizard_${AUTO_WIZARD_VERSION}
file: auto_wizard.json.tmpl
template_driver: golang
pg_backup:
name: ${STACK_NAME}_pg_backup_${PG_BACKUP_VERSION}
file: pg_backup.sh
secrets:
db_password:

34
pg_backup.sh Normal file
View File

@ -0,0 +1,34 @@
#!/bin/bash
set -e
BACKUP_FILE='/var/lib/postgresql/data/backup.sql'
function backup {
export PGPASSWORD=$(cat /run/secrets/db_password)
pg_dump -U ${POSTGRES_USER} ${POSTGRES_DB} > $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}
psql -U ${POSTGRES_USER} -d ${POSTGRES_DB} -1 -f $BACKUP_FILE
trap - EXIT INT TERM
restore_config
}
$@