Backup and restore¶
What to back up¶
| Data | Where | Why |
|---|---|---|
| Database | MariaDB/MySQL database userli |
All accounts, aliases, domains, settings, password hashes and the encrypted MailCrypt keys. |
| Configuration | .env.local or your environment variables |
Especially APP_SECRET and DATABASE_URL. |
| Customizations | translations/ in the installation directory |
Overridden texts, if any. |
The application code can be downloaded again and doesn't need a backup. The
cache (var/cache) and Redis contain no data that can't be rebuilt.
Database and mailboxes belong together
With MailCrypt, the keys to decrypt the mailboxes are only stored in the Userli database. Without a database backup, encrypted mailboxes can't be read anymore. Back up the database at least as often as the mailboxes and keep both for the same period.
Backups contain sensitive data
Database backups contain password hashes and encrypted private keys. Encrypt them and restrict access.
Database backup¶
mysqldump --single-transaction --routines --triggers userli | gzip > userli-$(date +%F).sql.gz
Run it regularly, for example as a systemd timer or cron job, and copy the backups to another host.
Restore¶
- Install the same Userli version that was running when the backup was made (see Install from release).
- Restore the configuration (
.env.local). -
Restore the database:
gunzip -c userli-2025-01-01.sql.gz | mysql userli -
Clear the cache and start the services:
bin/console cache:clear -
If you want to update to a newer version, do it afterwards as described in Updating.