Backups, restores and the restore drill
By the end you can
- List the scheduled jobs and what each one protects
- Name what is not in a backup and must be saved separately
- Restore a backup onto the same host
- Run and read the restore drill
Two kinds of backup
Authcha takes two independent database backups. Both contain everything in PostgreSQL: users, devices, policies, accounting, audit log and license.
Scheduled backups on the host
The installer sets up these jobs in /etc/cron.d/authcha.
| Job | When | What it does |
|---|---|---|
| Backup | Every 6 hours | Writes a compressed dump, radius-<timestamp>.dump, to /opt/authcha/backups/ with a .sha256 file. Next to it: the RADIUS certificate volume (including the server key), the RADIUS clients and saved site policies, and a small text file with the version and a short fingerprint of the encryption key. Files older than 14 days are removed. .env is not included. |
| Restore drill | Sundays 02:00 | Restores the latest dump into a temporary database, checks the key tables are filled, checks the archives, and proves that the key in .env can decrypt every encrypted secret in the restored copy. Then it deletes the temporary database |
| Audit retention | Daily 03:00 | Archives security logs older than 180 days, then removes them from the database |
Run them yourself whenever you like:
sudo authcha backup # back up now
sudo authcha backup verify # drill the newest dumpConsole backups
The console also writes a daily compressed SQL backup to its own storage and keeps it for 30 days by default (BACKUP_RETENTION_DAYS; 0 turns it off). List and download them under System → Automated backups. Backup database on the same page downloads a fresh one at any moment. Do this before every upgrade.
What you must back up yourself
| What | Why |
|---|---|
The backups/ directory | The scheduled backups live on the same host. Copy them off it. Set BACKUP_OFFSITE_PATH=backup@host:/srv/authcha-backups/ and every dump is synced there with rsync over SSH |
.env and otp.env | They hold every bootstrap secret and are not in the database backup. Store them encrypted. PKI_KEY_ENCRYPTION_KEY matters most: without it, the certificate authority keys, identity-provider signing keys and MDM secrets in every backup cannot be read |
| Your own TLS certificate and key | In /opt/authcha/config/tls/, if you supplied them |
| Audit archives | In backups/audit-archive/, if regulations require logs beyond the retention window |
Restore
Stop the services that use the database and make an empty one:
cd /opt/authcha
docker compose stop admin freeradius
docker compose exec db dropdb -U radius radius
docker compose exec db createdb -U radius radiusLoad a scheduled backup, after checking its checksum:
sha256sum -c backups/radius-20260901T000000Z.dump.sha256
docker compose exec -T db pg_restore -U radius -d radius --no-owner --no-acl --exit-on-error \
< backups/radius-20260901T000000Z.dumpA console backup (.sql.gz) loads with gunzip -c file | docker compose exec -T db psql -U radius -d radius -q -v ON_ERROR_STOP=1.
Then put back the RADIUS certificates from the matching archive, put the same PKI_KEY_ENCRYPTION_KEY back in .env, recreate every container (do not just restart) and check the key:
docker compose up -d --force-recreate
sudo authcha kek-checkkek-check prints how many items of each kind it decrypted. If it fails, the key in .env is not the one the backup was made with.
The restore drill
A backup is only worth what a restore proves. Run the drill after installing, after every upgrade and at least once a quarter.
sudo authcha backup, and wait.sudo authcha backup verify. It must end withdrill PASSED.- At least once, restore for real onto a spare host with the escrowed key, run
sudo authcha kek-check, sign in and authenticate one 802.1X client. Write down the date and the result.
The weekly job does step 2. If it warns KEK not verified, the admin image or .env was not available to it. Fix that, because a drill that skips the key check can pass on a backup you could not actually use. Check its log now and then:
tail -n 20 /var/log/authcha-restore-drill.logLabHands-on
Needs your own install (or a test VM).
- Run
sudo authcha backup. List/opt/authcha/backups/and find the dump, its.sha256and the companion files. - Open System → Automated backups in the console and download the newest one.
- Run
sudo authcha backup verify. Confirmdrill PASSED. - Check the weekly drill's log with
tail -n 20 /var/log/authcha-restore-drill.log. - Set
BACKUP_OFFSITE_PATHto another host you control, recreate theadminservice, run a backup and confirm the files arrive there. - On a spare host with the same Authcha version, do a full restore with the escrowed key. Run
sudo authcha kek-check, sign in and write down the date.
Check yourselfQuiz
Cheat sheetKeep this
- Scheduled: backup every 6 h, drill Sundays 02:00, audit retention daily 03:00. Kept 14 days on the host.
- Console backup: daily, 30 days, under System → Automated backups.
- Now:
sudo authcha backup,sudo authcha backup verify. - Not in the backup:
.env,otp.env, your TLS key. Escrow the encryption key separately. - Restore: stop
admin freeradius, drop and create the database,pg_restore, restore certs, same key, recreate everything,sudo authcha kek-check. - Drill after install, after each upgrade, and at least quarterly. Do one real restore.
- Read more: Operations.