Zammad Backup: Step-by-Step Guide for Package and Docker
Learn how to backup and restore Zammad on package or Docker. Step-by-step guide covering database, files, Elasticsearch, and best practices for data recovery.
- Zammad backups capture database, files, and Elasticsearch indexes automatically via built-in scripts.
- Package installations use a cron-scheduled backup script; Docker runs nightly backups in a container.
- Restores require stopping Zammad, running a restore script, and rebuilding Elasticsearch indexes for search to work again.
- Backups stored on the same server fall to ransomware or hardware failure; always replicate off-site.
- Elasticsearch rebuild takes 5-15 minutes depending on ticket volume, so plan for 15-30 minutes total downtime during recovery.
Backing up your Zammad helpdesk protects your ticket history, customer communications, and configuration. Both package-based and Docker deployments include built-in backup tools, but managing them yourself requires discipline. If this operational burden sounds heavy, managed Zammad hosting handles backups automatically. This guide walks you through every step for self-managed backup and recovery.
Why Backup Matters for Zammad
Zammad stores every support ticket, customer interaction, and agent configuration in a live database. If that database is lost to hardware failure, human error, or ransomware, your entire ticket history disappears. Backups solve this, but they're only useful if you can restore them reliably. Most Zammad deployments run on a single server without redundancy, making backups your only insurance policy. Recovery Point Objective (RPO) -- how much data you can afford to lose -- and Recovery Time Objective (RTO) -- how long your team tolerates downtime -- drive backup frequency and storage strategy. A nightly backup keeps your RPO to 24 hours. If your team needs faster recovery, automate off-site replication or consider managed hosting.
What Gets Backed Up in Zammad
Zammad backups capture three critical components. First, the PostgreSQL or MySQL database: all tickets, users, groups, macros, and settings. Second, application files: code, custom extensions, and uploaded attachments. Third, Elasticsearch indexes (if enabled): the search engine that powers ticket search. The backup scripts compress both into timestamped files. What they don't capture: environment variables, SSL certificates, OS-level firewall rules, or systemd configuration. Those live on the host and must be backed up separately or documented. After restore, you rebuild the Elasticsearch index from the database using a rake task, so the archive doesn't need a full Elasticsearch snapshot. This design makes backups smaller but requires extra steps on recovery.
Backing Up Package-Based Zammad (Linux)
Package installations on Linux (the default) use Zammad's built-in backup script. First, verify your configuration is in place:
sudo cat /etc/zammad/config.dist | sudo tee /etc/zammad/config
This copies the distribution config to the live location if missing. Next, run the backup:
sudo /opt/zammad/script/backup
The script compresses the database and file system into two archive files in /var/tmp/zammad:
_zammad_db.psql.gz(database dump, typically 50MB-1GB depending on ticket volume)_zammad_files.tar.gz(application files and uploads, typically 100MB-2GB)
Verify the files exist and have recent timestamps:
ls -lah /var/tmp/zammad/*_zammad_*.gz
Non-zero file size means the backup succeeded. Zero-size files mean an error occurred; check the system logs for details. Backups run synchronously, so the script blocks while executing -- large instances may take 10-20 minutes. For automation, add a cron job:
0 2 * * * /opt/zammad/script/backup
This runs the backup nightly at 2 AM. The backup files are not automatically deleted, so set up a rotation script to prune backups older than 30 days:
find /var/tmp/zammad -name "*_zammad_*.gz" -mtime +30 -delete
Add this to cron as well, running after the backup:
0 3 * * * find /var/tmp/zammad -name "*_zammad_*.gz" -mtime +30 -delete
Backing Up Docker Compose Zammad
Docker Compose deployments automate backups using the zammad-backup service. Zammad's default Docker stack includes a nightly backup container that runs at 2 AM and dumps archives into a named volume. To verify your stack has it, check the docker-compose.yml for a zammad-backup service. If present, backups run automatically. To trigger a manual backup on demand:
docker compose run --rm --env BACKUP_ONCE=true zammad-backup
The archives go to /var/tmp/zammad/ inside the container, mounted to a Docker volume on the host. Locate the backup on your host system:
docker volume inspect zammad_zammad-backup | grep Mountpoint
Navigate to that path; you'll see the same two files: _zammad_db.psql.gz and _zammad_files.tar.gz. Copy backups to off-site storage using rsync or a cloud sync tool like Restic or duplicacy. For example, sync daily to an S3 bucket:
docker run --rm -v zammad_zammad-backup:/backup \
-e AWS_ACCESS_KEY_ID=your_key \
-e AWS_SECRET_ACCESS_KEY=your_secret \
amazon/aws-cli s3 sync /backup s3://your-backup-bucket/zammad/
Storing backups on the same server defeats the purpose. Ransomware or hardware failure wipes both the application and backups together. Plan for off-site replication from day one.
Restoring Zammad: Package Installation
Restore only on the same host (same OS version, same Zammad version) or a fresh host with identical setup. Prerequisites: at least as much disk space as the backup size, permissions to run sudo, and knowledge of your database type (PostgreSQL or MySQL). The restore script is at /opt/zammad/script/restore. First, stop Zammad:
sudo systemctl stop zammad
Place your backup files in the restore directory:
sudo cp /path/to/_zammad_db.psql.gz /opt/zammad/
sudo cp /path/to/_zammad_files.tar.gz /opt/zammad/
Run the restore script:
sudo /opt/zammad/script/restore
The script prompts for the database type (PostgreSQL vs MySQL) and then drops the live database, restores from the archive, and replaces application files. This is destructive: all current data is overwritten. After restore completes, start Zammad:
sudo systemctl start zammad
Elasticsearch indices are stale now. Rebuild them:
sudo -u zammad bundle exec rake zammad:searchindex:rebuild
This takes 5-15 minutes on large instances. Watch the logs while it runs:
sudo tail -f /var/log/zammad/*.log
Common restore errors: "Permission denied" means the script lacks write access to the database or file system (run as sudo); "Disk space" means your restore volume filled during extraction (resize or move backups elsewhere); "Database already exists" means the script couldn't drop the old database (verify Zammad is stopped and no other processes are using the database).
Restoring Zammad: Docker Compose
For Docker, stop the stack and clean up volumes before restore:
docker compose down
docker volume rm zammad_zammad-postgres zammad_zammad-data zammad_zammad-elasticsearch
Create the backup restore directory:
mkdir -p /var/lib/docker/volumes/zammad_zammad-backup/_data/restore
Place your backup files inside:
cp /path/to/_zammad_db.psql.gz /var/lib/docker/volumes/zammad_zammad-backup/_data/restore/
cp /path/to/_zammad_files.tar.gz /var/lib/docker/volumes/zammad_zammad-backup/_data/restore/
Start the stack. The restore container runs automatically on first boot and processes the files:
docker compose up -d
Monitor the restore progress:
docker compose logs -f zammad-backup
Once the restore finishes, verify Zammad is running:
docker compose ps
Then rebuild Elasticsearch:
docker compose run --rm zammad bundle exec rake zammad:searchindex:rebuild
The rebuild streams logs to your terminal. When it completes, cleanup:
docker compose run --rm --env DELETE_RESTORE_FILES=true zammad-backup
This deletes the restore archive from the volume, freeing space.
Backup Best Practices
Schedule backups to run during off-peak hours. If backups block ticket creation or API calls, your users notice. 2 AM to 3 AM is common for small teams; larger deployments may move backups to quiet Windows or use a secondary read-only replica. Test restores at least monthly on a non-production server. Backups you haven't tested are not backups: they're just files. A test restore catches corruption, missing files, or version incompatibility before disaster strikes. Rotate backups: keep daily backups for 30 days, weekly for 90 days, and monthly for a year. This balances storage costs against retention. On-site backups (same server or local NAS) recover fast but fall to ransomware or hardware failure. Off-site backups (cloud storage, remote server) add latency but survive site-wide disaster. Use both. For compliance (PCI DSS, GDPR), document your backup retention policy and store a copy signed with a timestamp. If your team doesn't have ops experience, consider managed Zammad hosting or alternatives to reduce this overhead.
When Self-Hosted Backups Aren't Right for You
Managing Zammad backups yourself requires discipline: testing restores, monitoring completion, rotating files, and syncing off-site. Each failure point adds operational risk. If your team has limited DevOps resources, Opsily manages backup and restore operations for Zammad, so your team can focus on support strategy instead of backup scripts.
Frequently Asked Questions
How do I restore from a Zammad backup?
Place the backup files in /opt/zammad/ (package) or /var/lib/docker/volumes/.../restore/ (Docker). Stop Zammad, run the restore script, then rebuild Elasticsearch indices using the rake task. The process overwrites all current data, so verify you have the correct backup first.
How long does a restore from a Zammad backup take?
Restore time depends on backup size and disk speed. A typical instance (200k tickets, 2GB backup) restores in 5-15 minutes on SSD. Elasticsearch rebuild adds another 5-15 minutes. Total downtime is usually 15-30 minutes.
What is the difference between backup and restore?
A backup is a copy of your data at a point in time. A restore is the process of returning your system to that state. Backup creates files; restore reads those files and rewrites your live database.
Can I restore a package backup to Docker?
No. The backup format is incompatible. Package backups expect a Linux systemd setup; Docker uses containerized PostgreSQL and volumes. You must restore to the same deployment type.
Do Zammad backups include my SSL certificate?
No. SSL certificates are stored on the host OS, outside the application. Back them up separately: sudo tar czf zammad-certs.tar.gz /etc/letsencrypt/ /etc/zammad/
What if my backup fails silently?
Check system logs: sudo journalctl -u zammad -n 100 for package installs, or docker compose logs zammad-backup for Docker. Verify disk space with df -h. Monitor each backup with cron-job output or a healthcheck script that alerts if no backup file appears within 24 hours.
Can I skip Elasticsearch rebuild after a restore?
No. Elasticsearch indices are rebuilt from scratch as part of the restore. Without them, the ticket search box returns no results, making the helpdesk unusable.
The Bottom Line
Zammad backups are automated and built in, but they're only useful if you understand what they protect, how to restore them, and how to test them regularly. Package installations and Docker require different restore procedures, and both need off-site replication to survive hardware failure or ransomware. If your team lacks the ops bandwidth to test backups monthly and monitor retention policies, managed hosting removes that burden. Explore Opsily's Zammad hosting to see how we handle backup and recovery automatically.