From bedc5a2d48dbb87e543f3d56e71e0c4c0ca166b7 Mon Sep 17 00:00:00 2001 From: Martin Gruner Date: Thu, 21 Nov 2024 10:27:06 +0100 Subject: [PATCH 1/9] Fixes #440 - zammad-backup not working with postgres 17 --- .github/tests.sh | 59 +++++++++++++++++------------------------------- 1 file changed, 21 insertions(+), 38 deletions(-) diff --git a/.github/tests.sh b/.github/tests.sh index 00e61f7..1dd1351 100755 --- a/.github/tests.sh +++ b/.github/tests.sh @@ -6,55 +6,38 @@ set -o errexit set -o pipefail +# Send the logs to STDOUT for debugging. docker compose logs --timestamps --follow & -echo -echo "wait for zammad to be ready..." -echo +# Print empty lines before and after the heading to find it between the logs. +print_heading() { + echo + echo "$1" + echo +} +print_heading "wait for zammad to be ready..." docker compose wait zammad-init curl --retry 30 --retry-delay 1 --retry-connrefused http://localhost:8080 | grep "Zammad" +print_heading "Success - Zammad is up :)" -echo -echo "Success - Zammad is up :)" -echo - -echo -echo "Execute autowizard..." -echo - +print_heading "Execute autowizard..." docker compose exec --env=AUTOWIZARD_RELATIVE_PATH=tmp/auto_wizard.json --env=DATABASE_URL=postgres://zammad:zammad@zammad-postgresql:5432/zammad_production zammad-railsserver bundle exec rake zammad:setup:auto_wizard +print_heading "Autowizard executed successful :)" -echo -echo "Autowizard executed successful :)" -echo - -echo -echo "Check DB for AutoWizard user" -echo - +print_heading "Check DB for AutoWizard user" docker compose exec --env=DATABASE_URL=postgres://zammad:zammad@zammad-postgresql:5432/zammad_production zammad-railsserver bundle exec rails r "p User.find_by(email: 'info@zammad.org')" | grep 'info@zammad.org' +print_heading "Check DB for AutoWizard user successfull :)" -echo -echo "Check DB for AutoWizard user successfull :)" -echo - -echo -echo "Fill DB with some random data" -echo - +print_heading "Fill DB with some random data" docker compose exec --env=DATABASE_URL=postgres://zammad:zammad@zammad-postgresql:5432/zammad_production zammad-railsserver bundle exec rails r "FillDb.load(agents: 1,customers: 1,groups: 1,organizations: 1,overviews: 1,tickets: 1)" +print_heading "DB fill successful :)" -echo -echo "DB fill successful :)" -echo - -echo -echo "Check if the Zammad user can write to FS storage" -echo - +print_heading "Check if the Zammad user can write to FS storage" docker compose exec zammad-railsserver touch storage/test.txt +print_heading "Storage write successful :)" -echo -echo "Storage write successful :)" -echo +print_heading "Check if zammad-backup created a backup" +docker compose exec zammad-backup sh -c "ls /var/tmp/zammad/* | grep zammad_db.psql.gz" +docker compose exec zammad-backup sh -c "ls /var/tmp/zammad/* | grep zammad_files.tar.gz" +print_heading "Zammad backup was created" From 8fe257adc54c62673e69a7898dfbab195960adfa Mon Sep 17 00:00:00 2001 From: Martin Gruner Date: Thu, 21 Nov 2024 10:51:00 +0100 Subject: [PATCH 2/9] Improve test to fail for empty DB backups --- .github/tests.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/tests.sh b/.github/tests.sh index 1dd1351..1cafe44 100755 --- a/.github/tests.sh +++ b/.github/tests.sh @@ -23,11 +23,11 @@ print_heading "Success - Zammad is up :)" print_heading "Execute autowizard..." docker compose exec --env=AUTOWIZARD_RELATIVE_PATH=tmp/auto_wizard.json --env=DATABASE_URL=postgres://zammad:zammad@zammad-postgresql:5432/zammad_production zammad-railsserver bundle exec rake zammad:setup:auto_wizard -print_heading "Autowizard executed successful :)" +print_heading "Autowizard executed successfully :)" print_heading "Check DB for AutoWizard user" docker compose exec --env=DATABASE_URL=postgres://zammad:zammad@zammad-postgresql:5432/zammad_production zammad-railsserver bundle exec rails r "p User.find_by(email: 'info@zammad.org')" | grep 'info@zammad.org' -print_heading "Check DB for AutoWizard user successfull :)" +print_heading "Check DB for AutoWizard user successful :)" print_heading "Fill DB with some random data" docker compose exec --env=DATABASE_URL=postgres://zammad:zammad@zammad-postgresql:5432/zammad_production zammad-railsserver bundle exec rails r "FillDb.load(agents: 1,customers: 1,groups: 1,organizations: 1,overviews: 1,tickets: 1)" @@ -38,6 +38,7 @@ docker compose exec zammad-railsserver touch storage/test.txt print_heading "Storage write successful :)" print_heading "Check if zammad-backup created a backup" -docker compose exec zammad-backup sh -c "ls /var/tmp/zammad/* | grep zammad_db.psql.gz" -docker compose exec zammad-backup sh -c "ls /var/tmp/zammad/* | grep zammad_files.tar.gz" -print_heading "Zammad backup was created" +docker compose exec zammad-backup sh -c "find /var/tmp/zammad/ -name \"*zammad_files.tar.gz\" | grep ." +# Check that the db dump actually has content in the .gz file to catch cases where pg_dump fails. +docker compose exec zammad-backup sh -c "find /var/tmp/zammad/ -name \"*zammad_db.psql.gz\" -size +1000000c | grep ." +print_heading "Zammad backup was created successfully :)" From 2074b4a70e4e5c91d89803334144e3c58c2945e3 Mon Sep 17 00:00:00 2001 From: Martin Gruner Date: Thu, 21 Nov 2024 10:54:54 +0100 Subject: [PATCH 3/9] Simplify file size check --- .github/tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/tests.sh b/.github/tests.sh index 1cafe44..57787ac 100755 --- a/.github/tests.sh +++ b/.github/tests.sh @@ -40,5 +40,5 @@ print_heading "Storage write successful :)" print_heading "Check if zammad-backup created a backup" docker compose exec zammad-backup sh -c "find /var/tmp/zammad/ -name \"*zammad_files.tar.gz\" | grep ." # Check that the db dump actually has content in the .gz file to catch cases where pg_dump fails. -docker compose exec zammad-backup sh -c "find /var/tmp/zammad/ -name \"*zammad_db.psql.gz\" -size +1000000c | grep ." +docker compose exec zammad-backup sh -c "find /var/tmp/zammad/ -name \"*zammad_db.psql.gz\" -size +1M | grep ." print_heading "Zammad backup was created successfully :)" From 35553e13c825051ef4586b0a5e4a6d6bc8de1284 Mon Sep 17 00:00:00 2001 From: Martin Gruner Date: Thu, 21 Nov 2024 10:57:24 +0100 Subject: [PATCH 4/9] Improve test output --- .github/tests.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/tests.sh b/.github/tests.sh index 57787ac..eca1f24 100755 --- a/.github/tests.sh +++ b/.github/tests.sh @@ -37,8 +37,11 @@ print_heading "Check if the Zammad user can write to FS storage" docker compose exec zammad-railsserver touch storage/test.txt print_heading "Storage write successful :)" -print_heading "Check if zammad-backup created a backup" +print_heading "Check if zammad-backup created an application backup" docker compose exec zammad-backup sh -c "find /var/tmp/zammad/ -name \"*zammad_files.tar.gz\" | grep ." +print_heading "Application backup successful :)" + +print_heading "Check if zammad-backup created a database backup" # Check that the db dump actually has content in the .gz file to catch cases where pg_dump fails. docker compose exec zammad-backup sh -c "find /var/tmp/zammad/ -name \"*zammad_db.psql.gz\" -size +1M | grep ." -print_heading "Zammad backup was created successfully :)" +print_heading "Database backup successful :)" From a2c41ea6fbec316ad0d25c4f8db871333eaa1bc4 Mon Sep 17 00:00:00 2001 From: Martin Gruner Date: Thu, 21 Nov 2024 11:11:38 +0100 Subject: [PATCH 5/9] Update to new Zammad image --- .env.dist | 2 +- docker-compose.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.env.dist b/.env.dist index 8543566..d3c8d65 100644 --- a/.env.dist +++ b/.env.dist @@ -15,7 +15,7 @@ # REDIS_VERSION=7.4.1-alpine # RESTART=always # Use a fixed version. You are responsible to update this to newer patch level versions yourself. -# VERSION=6.4.0-17 +# VERSION=6.4.0-26 # You can also use floating versions that will give you automatic updates: # VERSION=6.2 # all patchlevel updates # VERSION=6 # including minor updates diff --git a/docker-compose.yml b/docker-compose.yml index 848cab3..6a6387a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -36,7 +36,7 @@ x-shared: ZAMMAD_SESSION_JOBS: ZAMMAD_PROCESS_SCHEDULED: ZAMMAD_PROCESS_DELAYED_JOBS_WORKERS: - image: ${IMAGE_REPO:-ghcr.io/zammad/zammad}:${VERSION:-6.4.0-17} + image: ${IMAGE_REPO:-ghcr.io/zammad/zammad}:${VERSION:-6.4.0-26} restart: ${RESTART:-always} volumes: - zammad-storage:/opt/zammad/storage From 7372d92443452a598f42cbb1b89895dd152af74e Mon Sep 17 00:00:00 2001 From: Martin Gruner Date: Thu, 21 Nov 2024 11:17:21 +0100 Subject: [PATCH 6/9] Improve output --- .github/tests.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/tests.sh b/.github/tests.sh index eca1f24..ccb023a 100755 --- a/.github/tests.sh +++ b/.github/tests.sh @@ -11,9 +11,9 @@ docker compose logs --timestamps --follow & # Print empty lines before and after the heading to find it between the logs. print_heading() { - echo - echo "$1" - echo + echo ">" + echo "> $1" + echo ">" } print_heading "wait for zammad to be ready..." From d32ce630c69bd0a6769b515b0a9765f994bc01b1 Mon Sep 17 00:00:00 2001 From: Martin Gruner Date: Thu, 21 Nov 2024 11:21:12 +0100 Subject: [PATCH 7/9] Fix test --- .github/tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/tests.sh b/.github/tests.sh index ccb023a..9ab0d10 100755 --- a/.github/tests.sh +++ b/.github/tests.sh @@ -43,5 +43,5 @@ print_heading "Application backup successful :)" print_heading "Check if zammad-backup created a database backup" # Check that the db dump actually has content in the .gz file to catch cases where pg_dump fails. -docker compose exec zammad-backup sh -c "find /var/tmp/zammad/ -name \"*zammad_db.psql.gz\" -size +1M | grep ." +docker compose exec zammad-backup sh -c "find /var/tmp/zammad/ -name \"*zammad_db.psql.gz\" -size +100K | grep ." print_heading "Database backup successful :)" From ec86b855d047528622f70ddd295135321b7afa94 Mon Sep 17 00:00:00 2001 From: Martin Gruner Date: Thu, 21 Nov 2024 11:27:02 +0100 Subject: [PATCH 8/9] Debug --- .github/tests.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/tests.sh b/.github/tests.sh index 9ab0d10..69d5912 100755 --- a/.github/tests.sh +++ b/.github/tests.sh @@ -43,5 +43,6 @@ print_heading "Application backup successful :)" print_heading "Check if zammad-backup created a database backup" # Check that the db dump actually has content in the .gz file to catch cases where pg_dump fails. +docker compose exec zammad-backup sh -c "ls -lah /var/tmp/zammad/" docker compose exec zammad-backup sh -c "find /var/tmp/zammad/ -name \"*zammad_db.psql.gz\" -size +100K | grep ." print_heading "Database backup successful :)" From 3d1140169d3c963b269409e4d220d9d87859ff90 Mon Sep 17 00:00:00 2001 From: Martin Gruner Date: Thu, 21 Nov 2024 11:31:51 +0100 Subject: [PATCH 9/9] Fixed test --- .github/tests.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/tests.sh b/.github/tests.sh index 69d5912..84f0a6c 100755 --- a/.github/tests.sh +++ b/.github/tests.sh @@ -43,6 +43,5 @@ print_heading "Application backup successful :)" print_heading "Check if zammad-backup created a database backup" # Check that the db dump actually has content in the .gz file to catch cases where pg_dump fails. -docker compose exec zammad-backup sh -c "ls -lah /var/tmp/zammad/" -docker compose exec zammad-backup sh -c "find /var/tmp/zammad/ -name \"*zammad_db.psql.gz\" -size +100K | grep ." +docker compose exec zammad-backup sh -c "find /var/tmp/zammad/ -name \"*zammad_db.psql.gz\" -size +100k | grep ." print_heading "Database backup successful :)"