ZAMMAD Restore from multi instance docker

I have alos ask in this forum https://help.univention.com/t/zammad-restore-in-docker/16913

root@ucs1:/var/lib/univention-appcenter/apps/zammad/data/zammad/contrib/backup# docker ps
CONTAINER ID        IMAGE                                                               COMMAND                  CREATED             STATUS              PORTS                                            NAMES
d455eaf4e2dc        docker.software-univention.de/zammad-zammad-nginx:3.5.0-3           "/docker-entrypoint.…"   18 hours ago        Up 18 hours         0.0.0.0:40001->80/tcp                            zammad_zammad-nginx_1
8d097fd06bb5        docker.software-univention.de/zammad-zammad-scheduler:3.5.0-3       "/docker-entrypoint.…"   18 hours ago        Up 18 hours                                                          zammad_zammad-scheduler_1
f24942ccbbf3        docker.software-univention.de/zammad-zammad-websocket:3.5.0-3       "/docker-entrypoint.…"   18 hours ago        Up 18 hours                                                          zammad_zammad-websocket_1
14dfd419171a        docker.software-univention.de/zammad-zammad-backup:3.5.0-3          "/usr/local/bin/back…"   18 hours ago        Up 18 hours         5432/tcp                                         zammad_zammad-backup_1
5cab3659bfa2        docker.software-univention.de/zammad-zammad-railsserver:3.5.0-3     "/docker-entrypoint.…"   18 hours ago        Up 18 hours                                                          zammad_zammad-railsserver_1
b02f6dcdc586        docker.software-univention.de/zammad-zammad-elasticsearch:3.5.0-3   "/tini -- /usr/local…"   18 hours ago        Up 18 hours         9200/tcp, 9300/tcp                               zammad_zammad-elasticsearch_1
3cc949153423        docker.software-univention.de/zammad-zammad-postgresql:3.5.0-3      "docker-entrypoint.s…"   18 hours ago        Up 18 hours         5432/tcp                                         zammad_zammad-postgresql_1
296b63e232f4        docker.software-univention.de/zammad-zammad-memcached:3.5.0-3       "docker-entrypoint.s…"   18 hours ago        Up 18 hours         11211/tcp                                        zammad_zammad-memcached_1

Actual behavior:

if I connect inside the backup container I can backup my zammad but I am
Unable to restore from there

Steps to reproduce the behavior:

root@ucs1:/# docker exec -it zammad_zammad-backup_1 /bin/bash
bash-5.0# /opt/zammad/contrib/backup/zammad_restore.sh

# Zammad restored started - Tue Jan  5 10:27:45 UTC 2021!

The restore will delete your current config and database!
Be sure to have a backup available!

Enter 'yes' if you want to proceed!
Restore?: yes
Enter file date to restore:
20201224164307
20210104163206
20210105082916
File date: 20201224164307
Enter db date to restore:
20201224164307
20210104163206
20210105082916
DB date: 20201224164307
# Stopping Zammad
/opt/zammad/contrib/backup/functions: line 132: service: command not found
# Restoring Files
# Ensuring correct file rights ...
chown: unknown user/group zammad:zammad
# Checking requirements
# ... Dropping current database zammad_production
env: can't execute 'ruby': No such file or directory
# ... Creating database zammad_production for owner zammad
env: can't execute 'ruby': No such file or directory
# Restoring PostgrSQL DB
psql: could not connect to server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
# Starting Zammad
/opt/zammad/contrib/backup/functions: line 132: service: command not found

# Zammad restored successfully - Tue Jan  5 10:27:59 UTC 2021!

Off course in this instance is not the postgres DB nor railserver or service (function line 132:)

so i wonder in which environment i have to run a restore…

inside the container zammad_zammad-backup_1 there is a script which seems to call the correct environment for backup

root@ucs1:/var/lib/univention-appcenter/apps/zammad/conf# docker exec -it zammad_zammad-backup_1 /bin/bash
bash-5.0# cat /usr/local/bin/backup.sh
#!/bin/bash

set -e

: "${ZAMMAD_DIR:=/opt/zammad}"
: "${BACKUP_DIR:=/var/tmp/zammad}"
: "${ZAMMAD_RAILSSERVER_HOST:=zammad-railsserver}"
: "${ZAMMAD_RAILSSERVER_PORT:=3000}"
: "${POSTGRESQL_HOST:=zammad-postgresql}"
: "${POSTGRESQL_PORT:=5432}"
: "${POSTGRESQL_DB:=zammad_production}"

function check_railsserver_available {
  until (echo > /dev/tcp/${ZAMMAD_RAILSSERVER_HOST}/${ZAMMAD_RAILSSERVER_PORT}) &> /dev/null; do
    echo "waiting for railsserver to be ready..."
    sleep 60
  done
}

function zammad_backup {
  TIMESTAMP="$(date +'%Y%m%d%H%M%S')"

  echo "${TIMESTAMP} - backuping zammad..."

  # delete old backups
  if [ -d "${BACKUP_DIR}" ] && [ -n "$(ls "${BACKUP_DIR}")" ]; then
    find "${BACKUP_DIR}"/*_zammad_*.gz -type f -mtime +"${HOLD_DAYS}" -exec rm {} \;
  fi

  if [ "${NO_FILE_BACKUP}" != "yes" ]; then
    # tar files
    tar -czf "${BACKUP_DIR}"/"${TIMESTAMP}"_zammad_files.tar.gz "${ZAMMAD_DIR}"
  fi

  #db backup
  pg_dump --dbname=postgresql://"${POSTGRESQL_USER}:${POSTGRESQL_PASSWORD}@${POSTGRESQL_HOST}:${POSTGRESQL_PORT}/${POSTGRESQL_DB}" | gzip > "${BACKUP_DIR}"/"${TIMESTAMP}"_zammad_db.psql.gz
}

if [ "$1" = 'zammad-backup' ]; then

  check_railsserver_available

  while true; do
    zammad_backup

    # wait until next backup
    sleep "${BACKUP_SLEEP}"
  done
fi

if [ "$1" = 'zammad-backup-once' ]; then
  check_railsserver_available

  zammad_backup
fi

if [ "$1" = 'zammad-backup-db' ]; then
  NO_FILE_BACKUP="yes"

  zammad_backup
fi
bash-5.0#

How this can be used for the

/opt/zammad/contrib/backup/zammad_restore.sh

same problem here

a new install with docker-compose zammad 3.6.0
git clone …
cd zammad
docker-compose up -d
wait a min.
in browser show the welcome screen

docker-compose exec zammad-backup /bin/bash
cp /opt/zammad/contrib/backup/config.dist /opt/zammad/contrib/backup/config
cd /opt/zammad/contrib/backup

bash-5.0# bash zammad_restore.sh
# Zammad restored started - Wed Jan  6 14:04:58 UTC 2021!

The restore will delete your current config and database! 
Be sure to have a backup available! 

Enter 'yes' if you want to proceed!
Restore?: yes
Enter file date to restore: 
20210106135544
File date: 20210106135544
Enter db date to restore: 
20210106135544
DB date: 20210106135544
# Stopping Zammad
/opt/zammad/contrib/backup/functions: line 132: service: command not found
# Restoring Files
# Ensuring correct file rights ...
chown: unknown user/group zammad:zammad
# Checking requirements
# ERROR: User 'zammad' is not present, but should be by default! #
# Restoration was NOT successfull, exitting ...

if i start the restore a second:

bash-5.0# bash zammad_restore.sh
# Zammad restored started - Wed Jan  6 14:06:49 UTC 2021!

The restore will delete your current config and database! 
Be sure to have a backup available! 

Enter 'yes' if you want to proceed!
Restore?: yes
Enter file date to restore: 
20210106135544
File date: 20210106135544
Enter db date to restore: 
20210106135544
DB date: 20210106135544
# Stopping Zammad
/opt/zammad/contrib/backup/functions: line 131: service: command not found
# Restoring Files
# Ensuring correct file rights ...
chown: unknown user/group zammad:zammad
# Restoring PostgrSQL DB
sh: psql: not found
# Starting Zammad
/opt/zammad/contrib/backup/functions: line 131: service: command not found

# Zammad restored successfully - Wed Jan  6 14:06:55 UTC 2021!

docker-compose up -d
wait a min
in browser show the welcome screen

The problem is obviously the backup script as well as the restore script are for a host envirnonment not for a docker install.
so the docker container zammad-backup does not have a user or group zammad:zammad
the docker container zammad-backup does not find the container of the postgresql DB
the docker container can not use the service command in order to stop the service zammad

so the backup and the restore scripts have to be adapted in order to work in docker environment

have a look at https://community.zammad.org/t/how-to-restore-zammad-backup-in-docker-compose-install/1831 , i will try also, if this approach works…

yes :confused:

How to restore the zammad backup? · Issue #68 · zammad/zammad-docker-compose · GitHub dont work for me.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.