Another missing feature of my OTRS docker containers was the automation of the backup files. OTRS already includes a backup script, and we also included a convenience script that runs that script with default parameter values (full backups, gzip compressed), which you could run on an already running container or automate it from the docker host using cron and docker exec.
This approach wasn't flexible enough and needed configuration on the host side, which in some way goes against the point of containing an application configuration and runtime in one place.
So now a new feature has been added to configure and run the backup process which can be controlled with the following environment variables:
- OTRS_BACKUP_TIME: Sets the backup excecution time, in cron format. If set to "disable" automated backups will be disabled.
- OTRS_BACKUP_TYPE: Sets the type of backup, it receives the same values as the OTRS backup script:
- fullbackup: Saves the database and the whole OTRS home directory (except /var/tmp and cache directories). This is the default.
- nofullbackup: Saves the database and the whole OTRS home directory (except /var/tmp and cache directories).
- dbonly: Only the database will be saved.
- OTRS_BACKUP_COMPRESSION: Sets the backup compression method to use, also it receives the same values as the OTRS backup script (gzip|bzip2). The default is gzip.
- OTRS_BACKUP_ROTATION: Sets the number of days to keep the backup files. The default is 30 days.
OTRS_BACKUP_TIME="0 12,12 * * *"
This feature is available since the 6.0.15 build.
RestoringTo restore a backup file (not necessarily created with this container) the following environment variables must be added to docker-compose.yml (or env file if using one as you should do):
- OTRS_INSTALL=restore Will restore the backup specified by OTRS_BACKUP_DATE environment variable.
- OTRS_BACKUP_DATE is the backup name to restore. It can have two values:
- Uncompressed backup: A directory with its name in the same date_time format that the OTRS backup script uses.
- Compressed backup file: A gzip tarball of the previously described directory with the backup files. These tarballs are created by this container when doing a backup.
For example setting OTRS_BACKUP_DATE=2018-12-15_00-30 will look for that directory inside /var/otrs/backups/, and restore the backup files inside it. Or you could set OTRS_BACKUP_DATE=otrs-2018-12-15_00_30-fulbackup.tar.gz and the script will look for that file in the same directory and restore it.
A backup file created with this image or with any OTRS installation will work (the backup script creates the directory with that name). This is useful when migrating from another OTRS install to this container. I know that some of the variable names are a little confusing, probably will be renamed at a later version.