Create and restore backups of your HumHub installation: database, modules, configuration, uploads and a custom theme.
The module creates and restores backups of your HumHub installation. Only system administrators can use it. Open it via Administration → Modules → Backup → Configure.
A backup is a ZIP file that can contain:
| Component | Source |
|---|---|
| Database | complete dump (mysqldump / mariadb-dump), without the job queue tables |
| Modules | all module directories from moduleAutoloadPaths except @humhub/modules and except directories that contain no modules (by default @app/modules; in the official Docker image /data/modules and /data/modules-custom - @app/modules is root owned and empty, so it is skipped) |
| Configuration | @config (includes the database credentials) |
| Uploads | the uploads directory |
| Theme | one custom theme from @themes/<name> |
backup-info.json inside the archive records for each component whether it was included, partial (some files unreadable) or missing (directory not found). Such problems are also shown after the backup finished.
Backups contain personal data (accounts, e-mail addresses, private content) and credentials. Store and transfer them securely.
The job queue tables (queue, queue_exclusive) are never part of a backup and are never replaced by a restore. Otherwise the backup job that was running when the dump was taken would come back as a "reserved" job, and a restore would wipe the jobs that are currently waiting.
@runtime/backups) or absolute path. It must be below @runtime or outside of the web root.@themes (required if "Backup Theme" is enabled).A restore overwrites module code and configuration, so it must not trust every humhub_backup_*.zip that happens to lie in the backup directory. Therefore:
<backup>.zip.sig next to it). The key is a secret of this installation and is not stored in the backup directory (see INSTALLATION.md).Deleting a backup also deletes its signature file. A downloaded backup does not include the signature, so restoring it on another server always needs the extra confirmation.
Backups are ZIP files; the Compression setting controls how the contents are compressed:
| Setting | What happens | Notes |
|---|---|---|
| Standard | every file is compressed on its own (ZIP), already compressed files such as images, videos and archives are stored as they are | fastest, can be opened with any ZIP tool |
| Smaller (gzip) | each module directory and the theme is compressed as one archive (.tar.gz) inside the ZIP | smaller, a bit slower |
| Smallest (bzip2) | like gzip but with bzip2, and the database dump is compressed with bzip2 as well | smallest, slowest, needs the PHP bz2 extension |
Why not a ZIP per module? A ZIP inside a ZIP does not save anything, because the files inside are already compressed and the outer ZIP can only store them. What makes the difference is compressing many files as one stream: source code, CSS and JavaScript contain a lot of repeated text across files, which a per-file compression cannot use.
Measured with the module itself:
| Content | Standard | gzip | bzip2 |
|---|---|---|---|
| 581 PHP files (4.95 MB) | 1.43 MB | 1.01 MB (-29%) | 0.78 MB (-45%) |
| Code plus documentation with images (32.7 MB) | 20.5 MB | 17.4 MB (-15%) | 16.6 MB (-19%) |
The savings depend on the content: source code gains the most, images and videos (uploads) gain nothing and are therefore never recompressed. Creating a compressed backup needs temporary disk space in the backup directory for the compressed archive (before it is added to the ZIP), and restoring needs temporary space in @runtime for the unpacked files.
The compressed parts are standard .tar.gz / .tar.bz2 files. If the server does not support the selected compression, the backup uses the next best option and reports it. A backup can only be restored on a server that supports the compression it was made with; otherwise the restore is refused before anything is changed.
Click Create Backup. The backup runs in the background; the page shows its state and refreshes when it has finished. Only one backup or restore can run at a time. If an operation hangs (for example because the queue worker stopped), use Reset status.
Click the restore button of a backup. A confirmation page shows
Before you restore:
To start the restore, tick the checkbox and type RESTORE (for a backup that is not signed by this installation you also have to confirm that you trust it). The restore runs as a background job. Before anything is changed it unpacks the backup and checks every file: each file that has to be overwritten must be writable by the web server user, new files must be creatable, and the database tools must be available. Files that are identical to the backup are left alone and do not need to be writable. If a file cannot be written, the restore is refused with the affected files listed, and nothing is changed.
If a file part still fails while it is being restored (for example because the disk is full), the remaining parts and the database import are not started, so the database is never replaced while the files are not. When it has finished, the result lists every component that was restored and every part that could not be restored. If some parts failed, your installation may be inconsistent - restore the fresh backup you created before.
For a backup that was not verified by its signature (and that you confirmed as trusted), the database client is started in a restricted mode where the client has one (--sandbox for MariaDB, --commands=OFF for MySQL 8.4+ if the dump has no DELIMITER commands). This prevents client commands in the dump, such as \!, from running. If the client has no suitable mode, the result says so.
You may be logged out afterwards because the sessions stored in the database are replaced.
A restore needs a running HumHub (it runs in the queue), so it is meant for restoring an existing installation. To recover onto a new server, install HumHub there first (this creates the queue tables), enable this module and then restore the backup. The module directories stored in the backup must also exist in the moduleAutoloadPaths of the target installation, otherwise the restore is refused with an explanation.
mysqldump/mariadb-dump and the mysql/mariadb client and enable exec().gm-backup), then use Reset status.Disabling or uninstalling the module does not delete existing backups. They stay in the backup directory and must be removed manually (they contain personal data).