How to Backup and Restore Zammad
For some years now we have been using Zammad as support or helpdesk software in our school. We are very satisfied with Zammad because it offers many features and an easy to use user interface. Some time ago we had to move our server and therefore our Zammad installation. In this article I would like to briefly show how to backup and restore Zammad.
Backup Zammad
Zammad provides a backup script, but it is disabled by default. You can use the script to make regular backups. The script is located at /opt/zammad/contrib/backup/. The backup script reads a configuration file in which all important settings are made. You have to rename this file first:
$ mv /opt/zammad/contrib/backup/config.dist /opt/zammad/contrib/backup/config
Then you open the file and can adjust a few things:
$ nano /opt/zammad/contrib/backup/config...
BACKUP_DIR='/var/tmp/zammad_backup'
HOLD_DAYS='10'
DEBUG='no'
BACKUP_DIR specifies where the backups are to be stored. The directory must exist! HOLD_DAYS specifies how long a backup or how many backups should be stored.
Now you can execute the backup script:
$ cd /opt/zammad/contrib/backup
$ ./zammad_backup.sh
The script creates two archives (database backup and Zammad folder) which are now located in the configured backup folder.
Note: If you want to migrate an installation, it is a good idea to stop Zammad first and then create the backup. However, this is only important for larger installations.
Restore Zammad
If you want to restore a backup on the same host, you can do this with the restore script:
$ cd /opt/zammad/contrib/backup
$ ./zammad_restore.sh
Done 🙂
However, if you want to move a Zammad installation (migration, reinstallation), there are some things to keep in mind:
- Zammad must be installed (including Elasticsearch)
- the Zammad version should be the same or higher (than the backup version)
- The same database should be used (a change is possible, but very time-consuming, since the data must be adapted).
- There should be enough free space (about 2x as much as the size of the backup).
If all conditions are met, you must first enable the configuration on the destination server:
$ mv /opt/zammad/contrib/backup/config.dist /opt/zammad/contrib/backup/config
Then copy the backup files into the configured backup folder (with cp or if you are using LXD containers with lxc file push/pull) and finally run the recovery script:
$ cd /opt/zammad/contrib/backup
$ ./zammad_restore.sh
See the official documentation for more information.
Conclusion
Zammad comes with a simple backup and restore mechanism that works reliably. If you don’t back up your Zammad installation elsewhere, you can also set up a cron job for the backup script to make a regular backup.
Originally published at https://openschoolsolutions.org.