9 Commits

Author SHA1 Message Date
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
d68c9ad18c chore: publish 1.0.4+6.3.1-95 release 2024-09-19 23:34:07 +02:00
38682b8503 add backupbot label 2024-09-19 23:23:06 +02:00
ce314169cb move zammad internal backups to compose overwrite 2024-09-19 23:18:28 +02:00
34be0c287e fix elasticsearch resources limits 2024-09-19 23:12:12 +02:00
aab7e022d0 chore: publish 1.0.3+6.3.1-95 release 2024-09-17 12:49:44 +02:00
a7e409b337 fix set_logo and enable_authentik_sso 2024-09-17 12:46:33 +02:00
ffe4fa1c54 fix init: remove LOGO_URL 2024-09-03 19:12:30 +02:00
7 changed files with 94 additions and 63 deletions

View File

@ -7,6 +7,7 @@ TIMEOUT=600
#EXTRA_DOMAINS=', `www.zammad.example.com`' #EXTRA_DOMAINS=', `www.zammad.example.com`'
LETS_ENCRYPT_ENV=production LETS_ENCRYPT_ENV=production
COMPOSE_FILE="compose.yml"
SECRET_DB_PASSWORD_VERSION=v1 SECRET_DB_PASSWORD_VERSION=v1
SECRET_SMTP_PASSWORD_VERSION=v1 SECRET_SMTP_PASSWORD_VERSION=v1
@ -18,10 +19,6 @@ PRODUCT_NAME="Support"
ORGANIZATION="Test Org" ORGANIZATION="Test Org"
# TIMEZONE="Europe/Berlin" # TIMEZONE="Europe/Berlin"
LOCALE="de-de" LOCALE="de-de"
#TEXT_MUTED="#7e7e7e"
#MENU_TEXT="#7e7e7e"
#BACKGROUND_1="#7e7e7e"
#BACKGROUND_2="#7e7e7e"
ADMIN_EMAIL=admin@example.com ADMIN_EMAIL=admin@example.com
SMTP_HOST=mail.example.com SMTP_HOST=mail.example.com
@ -32,3 +29,9 @@ SMTP_PORT=465
#SSO_PROVIDER_DOMAIN=authentik.example.com #SSO_PROVIDER_DOMAIN=authentik.example.com
#IDP_SSO_TARGET_URL=https://authentik.example.com/application/saml/zammad/sso/binding/init/ #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://authentik.example.com/application/saml/zammad/slo/binding/redirect/
## Zammad internal backups
# COMPOSE_FILE="$COMPOSE_FILE:compose.backup.yml"
# BACKUP_TIME=03:00"
# HOLD_DAYS=10

14
abra.sh
View File

@ -1,6 +1,6 @@
export ENTRYPOINT_VERSION=v2 export ENTRYPOINT_VERSION=v2
export AUTO_WIZARD_VERSION=v1 export AUTO_WIZARD_VERSION=v2
export CUSTOM_STYLE_VERSION=v1 export PG_BACKUP_VERSION=v1
get_setting_changes() { 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))'" /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))'"
@ -36,7 +36,7 @@ enable_authentik_sso() {
'idp_cert_fingerprint'=>'', 'idp_cert_fingerprint'=>'',
'name_identifier_format'=>'urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress'}) 'name_identifier_format'=>'urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress'})
" "
abra app cmd -T -C support.dev.local-it.cloud zammad-railsserver rails_run "$(printf "%q " $COMMAND )" abra app cmd -T $DOMAIN zammad-railsserver rails_run "$(printf "%q " $COMMAND )"
} }
set_logo() { set_logo() {
@ -49,11 +49,5 @@ set_logo() {
logo_timestamp = Service::SystemAssets::ProductLogo.store(logo_content); logo_timestamp = Service::SystemAssets::ProductLogo.store(logo_content);
Setting.set('product_logo', logo_timestamp); Setting.set('product_logo', logo_timestamp);
" "
abra app cmd -T -C support.dev.local-it.cloud zammad-railsserver rails_run "$(printf "%q " $COMMAND )" abra app cmd -T $DOMAIN zammad-railsserver rails_run "$(printf "%q " $COMMAND )"
}
customize(){
apt update
apt install nodejs npm
/custom-entrypoint.sh "rails assets:precompile"
} }

View File

@ -46,10 +46,6 @@
"name": "organization", "name": "organization",
"value": "{{ env "ORGANIZATION" }}" "value": "{{ env "ORGANIZATION" }}"
}, },
{
"name": "product_logo",
"value": "{{ env "LOGO_URL" }}"
},
{ {
"name": "timezone_default", "name": "timezone_default",
"value": "{{ env "TZ" }}" "value": "{{ env "TZ" }}"

36
compose.backup.yml Normal file
View File

@ -0,0 +1,36 @@
version: "3.8"
services:
zammad-backup:
image: ghcr.io/zammad/zammad:6.3.1-95
command: ["zammad-backup"]
volumes:
- zammad-backup:/var/tmp/zammad
- zammad-storage:/opt/zammad/storage:ro
user: 0:0
deploy:
labels:
backupbot.backup.volumes.zammad-backup: "false"
restart_policy:
condition: on-failure
environment:
POSTGRESQL_DB: zammad_production
POSTGRESQL_HOST: zammad-postgresql
POSTGRESQL_USER: zammad
POSTGRESQL_PASS_FILE: /run/secrets/db_password
POSTGRESQL_PORT: 5432
# Backup settings
BACKUP_DIR: "/var/tmp/zammad"
BACKUP_TIME: "${BACKUP_TIME:-03:00}"
#BACKUP_SLEEP: 86400
HOLD_DAYS: 10
DOMAIN:
entrypoint: /custom-entrypoint.sh
configs:
- source: entrypoint
target: /custom-entrypoint.sh
mode: 0555
secrets:
- db_password
volumes:
zammad-backup:

View File

@ -13,11 +13,6 @@ x-shared:
POSTGRESQL_OPTIONS: ?pool=50 POSTGRESQL_OPTIONS: ?pool=50
POSTGRESQL_DB_CREATE: POSTGRESQL_DB_CREATE:
REDIS_URL: redis://zammad-redis:6379 REDIS_URL: redis://zammad-redis:6379
# Backup settings
BACKUP_DIR: "/var/tmp/zammad"
BACKUP_TIME: "${BACKUP_TIME:-03:00}"
#BACKUP_SLEEP: 86400
HOLD_DAYS: 10
TZ: "${TZ:-Europe/Berlin}" TZ: "${TZ:-Europe/Berlin}"
# Allow passing in these variables via .env: # Allow passing in these variables via .env:
AUTOWIZARD_JSON: AUTOWIZARD_JSON:
@ -37,10 +32,6 @@ x-shared:
ZAMMAD_SESSION_JOBS: ZAMMAD_SESSION_JOBS:
ZAMMAD_PROCESS_SCHEDULED: ZAMMAD_PROCESS_SCHEDULED:
ZAMMAD_PROCESS_DELAYED_JOBS_WORKERS: ZAMMAD_PROCESS_DELAYED_JOBS_WORKERS:
TEXT_MUTED: "${TEXT_MUTED:-hsl(213, 3%, 64%)}"
MENU_TEXT: "${MENU_TEXT:-hsl(0, 0%, 74%)}"
BACKGROUND_1: "${BACKGROUND_1:-hsl(231, 9%, 16%)}"
BACKGROUND_2: "${BACKGROUND_2:-hsl(233, 9%, 19%)}"
PRODUCT_NAME: PRODUCT_NAME:
ORGANIZATION: ORGANIZATION:
LOCALE: LOCALE:
@ -58,7 +49,6 @@ x-shared:
condition: on-failure condition: on-failure
volumes: volumes:
- zammad-storage:/opt/zammad/storage - zammad-storage:/opt/zammad/storage
#old: - zammad-data:/opt/zammad
depends_on: depends_on:
- zammad-memcached - zammad-memcached
- zammad-postgresql - zammad-postgresql
@ -70,32 +60,22 @@ x-shared:
mode: 0555 mode: 0555
- source: auto_wizard - source: auto_wizard
target: /opt/zammad/contrib/auto_wizard.json target: /opt/zammad/contrib/auto_wizard.json
- source: custom_style
target: /opt/zammad/app/assets/stylesheets/custom/custom_style.css
secrets: secrets:
- db_password - db_password
- smtp_password - smtp_password
- admin_password - admin_password
services: services:
zammad-backup:
<<: *zammad-service
command: ["zammad-backup"]
volumes:
- zammad-backup:/var/tmp/zammad
- zammad-storage:/opt/zammad/storage:ro
#old: - zammad-data:/opt/zammad
user: 0:0
deploy:
labels:
- "backupbot.backup=true"
- "backupbot.backup.path=/var/tmp/zammad"
zammad-elasticsearch: zammad-elasticsearch:
image: bitnami/elasticsearch:8.14.3 image: bitnami/elasticsearch:8.14.3
deploy: deploy:
restart_policy: restart_policy:
condition: on-failure condition: on-failure
resources:
limits:
memory: 4G
reservations:
memory: 2G
volumes: volumes:
- elasticsearch-data:/bitnami/elasticsearch/data - elasticsearch-data:/bitnami/elasticsearch/data
environment: environment:
@ -106,12 +86,6 @@ services:
timeout: 10s timeout: 10s
retries: 10 retries: 10
start_period: 5m start_period: 5m
deploy:
resources:
limits:
memory: 4G
reservations:
memory: 2G
zammad-init: zammad-init:
<<: *zammad-service <<: *zammad-service
@ -156,7 +130,7 @@ services:
- "traefik.http.routers.${STACK_NAME}.middlewares=${STACK_NAME}-redirect" - "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.SSLForceHost=true"
- "traefik.http.middlewares.${STACK_NAME}-redirect.headers.SSLHost=${DOMAIN}" - "traefik.http.middlewares.${STACK_NAME}-redirect.headers.SSLHost=${DOMAIN}"
- "coop-cloud.${STACK_NAME}.version=1.0.2+6.3.1-95" - "coop-cloud.${STACK_NAME}.version=1.0.5+6.3.1-95"
- "coop-cloud.${STACK_NAME}.timeout=${TIMEOUT:-120}" - "coop-cloud.${STACK_NAME}.timeout=${TIMEOUT:-120}"
healthcheck: healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080"] test: ["CMD", "curl", "-f", "http://localhost:8080"]
@ -174,10 +148,19 @@ services:
deploy: deploy:
restart_policy: restart_policy:
condition: on-failure condition: on-failure
labels:
backupbot.backup: "true"
backupbot.backup.pre-hook: "/pg_backup.sh backup"
backupbot.backup.volumes.postgresql-data.path: "backup.sql"
backupbot.restore.post-hook: '/pg_backup.sh restore'
backupbot.backup.volumes.elasticsearch-data: "false"
backupbot.backup.volumes.redis-data: "false"
volumes: volumes:
- postgresql-data:/var/lib/postgresql/data - postgresql-data:/var/lib/postgresql/data
# Backup Restore configs:
#- zammad-backup:/var/tmp/zammad:ro - source: pg_backup
target: /pg_backup.sh
mode: 0555
secrets: secrets:
- db_password - db_password
healthcheck: healthcheck:
@ -236,7 +219,6 @@ volumes:
elasticsearch-data: elasticsearch-data:
postgresql-data: postgresql-data:
redis-data: redis-data:
zammad-backup:
zammad-storage: zammad-storage:
networks: networks:
@ -252,10 +234,9 @@ configs:
name: ${STACK_NAME}_auto_wizard_${AUTO_WIZARD_VERSION} name: ${STACK_NAME}_auto_wizard_${AUTO_WIZARD_VERSION}
file: auto_wizard.json.tmpl file: auto_wizard.json.tmpl
template_driver: golang template_driver: golang
custom_style: pg_backup:
name: ${STACK_NAME}_custom_style_${CUSTOM_STYLE_VERSION} name: ${STACK_NAME}_pg_backup_${PG_BACKUP_VERSION}
file: custom_style.css.tmpl file: pg_backup.sh
template_driver: golang
secrets: secrets:
db_password: db_password:

View File

@ -1,6 +0,0 @@
:root {
--text-muted: {{ env "TEXT_MUTED" }};
--menu-text: {{ env "MENU_TEXT" }};
--background-quaternary: {{ env "BACKGROUND_1" }};
--background-tertiary: {{ env "BACKGROUND_2" }};
}

27
pg_backup.sh Normal file
View File

@ -0,0 +1,27 @@
#!/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/
# 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'
# 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
# Restore allowed connections
cat pg_hba.conf.bak > pg_hba.conf
su postgres -c 'pg_ctl reload'
}
$@