OTOBO Backup & Restore – Comprehensive Guide

OTOBO Backup & Restore – Comprehensive Guide
Section titled “OTOBO Backup & Restore – Comprehensive Guide”In this guide, we take a deep dive into backup strategies for OTOBO and examine:
- Database dump via
mysqldump - Backing up and restoring Docker volumes
- OTOBO-native scripts
backup.plandrestore.pl - Automation with cronjobs and error handling
- Long-term archiving (e.g., AWS S3)
1. Database dump with mysqldump
Section titled “1. Database dump with mysqldump”Advantage: Fast, platform-independent, contains almost all tickets, users, and settings.
Example command
Section titled “Example command”mysqldump \ --host=${DB_HOST} \ --user=${DB_USER} \ --password=${DB_PASS} \ --column-statistics=0 \ --single-transaction \ --databases otobo \ > /backup/otobo_db_$(date +'%Y%m%d_%H%M').sql--single-transaction: Minimizes table locks, OTOBO remains available.- Retention: e.g., hourly, last 72 dumps (3 days) via cron.
Cron job (hourly, 3-day retention)
Section titled “Cron job (hourly, 3-day retention)”0 * * * * /usr/local/bin/otobo_db_backup.sh
otobo_db_backup.shcreates a dump and deletes files older than 3 days.
Example script: otobo_db_backup.sh
Section titled “Example script: otobo_db_backup.sh”#!/bin/bashBACKUP_DIR="/backup/db"mkdir -p "$BACKUP_DIR"DATE=$(date +'%Y%m%d_%H%M')FILE="$BACKUP_DIR/otobo_db_${DATE}.sql.gz"
echo "Creating DB dump to $FILE"mysqldump --host=localhost --user=otobo \ --password=SecretPass --column-statistics=0 \ --single-transaction otobo | gzip > "$FILE"
# Delete old dumps (older than 3 days)find "$BACKUP_DIR" -type f -name '*.sql.gz' -mtime +3 -delete2. Docker volume backup
Section titled “2. Docker volume backup”All persistently stored files (attachments, configuration, logs) are located in Docker volumes.
2.1 Full backup of volumes
Section titled “2.1 Full backup of volumes”#!/bin/bashdate=DATE=$(date +'%d%m%Y_%H%M%S')# Shut down container for a consistent file systemdocker compose -f /opt/otobo-docker/compose.yml down
tar -czf "/tmp/docker_volumes_$DATE.tar.gz" /var/lib/docker/volumes
docker compose -f /opt/otobo-docker/compose.yml up -d --build- Down/Up: Guarantees a clean copy.
- Archive: GZ-compressed TAR in the host temp directory.
2.2 Restoration: Volumes & containers
Section titled “2.2 Restoration: Volumes & containers”#!/bin/bash# Usage: restore_volumes.sh backup_file.tar.gztar -xzf "$1" -C /# Remove old volumesdocker compose -f /opt/otobo-docker/compose.yml downrm -rf /var/lib/docker/volumes# Restore and restarttar -xzf "$1" -C /docker compose -f /opt/otobo-docker/compose.yml up -d3. OTOBO scripts: backup.pl & restore.pl
Section titled “3. OTOBO scripts: backup.pl & restore.pl”OTOBO provides its own CLI scripts in the container:
# Show help/opt/otobo/scripts/backup.pl -hOptions
Section titled “Options”| Option | Default | Description |
|---|---|---|
-d, --backup-dir | required | Target directory for backups |
-c, --compress | gzip | Compression method (gzip | bzip2) |
-r, --remove-old-backups DAYS | none | Deletes older backups (in days) |
-t, --backup-type | fullbackup | fullbackup (everything) | nofullbackup | dbonly |
fullbackup: Database + home directory (without cache).
dbonly: Database only.
Example: Full backup in the Docker container
Section titled “Example: Full backup in the Docker container”docker run --rm \ --volume otobo_opt_otobo:/opt/otobo \ --volume otobo_backup:/otobo_backup \ rotheross/otobo:latest-10_0 scripts/backup.pl \ --backup-dir /otobo_backup --compress gzip --remove-old-backups 7Restoration in the container
Section titled “Restoration in the container”docker run --rm \ --volume otobo_opt_otobo:/opt/otobo \ --volume otobo_backup:/otobo_backup \ rotheross/otobo:latest-10_0 scripts/restore.pl \ --backup-dir /otobo_backup/20231015_123045 --backup-dir /opt/otobo4. Automation & error handling
Section titled “4. Automation & error handling”Wrapper script with error checking
Section titled “Wrapper script with error checking”#!/bin/bashCOMPOSE_FILE="/opt/otobo-docker/compose.yml"# Start backupdocker compose -f "$COMPOSE_FILE" run --rm backupif [ $? -ne 0 ]; then echo "Backup failed" >&2 exit 1fiecho "Backup completed successfully"Old: Cron for volume backup
Section titled “Old: Cron for volume backup”0 */6 * * * /usr/local/bin/volume_backup.shCleaning up old backups
Section titled “Cleaning up old backups”#!/bin/bashBACKUP_DIR="/path/to/backups"echo "Removing backups older than 30 days in $BACKUP_DIR"find "$BACKUP_DIR" -mindepth 1 -mtime +30 -exec rm -rf {} \\ \;echo "Done."5. Long-term archive & cloud
Section titled “5. Long-term archive & cloud”- AWS S3: Upload of
.tar.gzand.sql.gzviaaws clior Python script. - rclone: Support for various targets (S3, Azure Blob, FTP).
- Advantage: Offsite storage, unlimited scaling.
Differences from other systems (backup context)
Section titled “Differences from other systems (backup context)”In the area of backup & restore, OTOBO and Znuny differ in the following aspects:
-
Container backups
- OTOBO: Official Docker image provides a pre-installed backup service with CLI hooks (
docker compose run backup), including prepared volume mounts and environment variables. - Znuny: Community Docker setups require manual addition of a backup container or customization of your own scripts.
- OTOBO: Official Docker image provides a pre-installed backup service with CLI hooks (
-
OTOBO CLI scripts
- OTOBO:
backup.plandrestore.plin the image support automatic cleanup options (--remove-old-backups), compression selection, and a single-transaction flag. - Znuny: Similar scripts exist, often without
--remove-old-backupsor advanced DB dump options; retrofitting via customization is necessary.
- OTOBO:
-
DB dump optimizations
- OTOBO: Standard flag
--single-transactionrecommended and documented to avoid locks; CLI ensures consistent usage. - Znuny: Community documentation usually refers to a simple dump without transaction protection, risk of locks under high load.
- OTOBO: Standard flag
-
Volume snapshot strategy
- OTOBO: Example scripts (e.g., full backup & restore) are the official reference and tested in multi-container environments.
- Znuny: Snapshot scripts vary greatly, official best practices are missing; users often have to define their own down/up sequences.
-
Automation & cloud plugins
- OTOBO: Integrated S3 uploader examples (Python script) and configuration modules for Azure, Google Cloud Storage.
- Znuny: No core plugins for cloud storage; solutions are usually external via
rcloneor separate upload scripts.
6. Conclusion
Section titled “6. Conclusion”With this focus on backup-specific differences, you can make an informed decision on whether to use the pre-built OTOBO mechanisms or extend Znuny setups individually.
6. Conclusion
Section titled “6. Conclusion”With these detailed scripts and strategies, your OTOBO data is securely backed up, ready for automation, and quickly restorable. Whether it’s a DB dump, Docker volumes, or standard OTOBO tools – you have all options under control.