Backups & Restore
TrixOS keeps all of its state in Postgres. Two things need a backup:
- The database, nightly.
- The
.envfile, once and after every change. It holdsTRIXOS_MASTER_KEY, which decrypts the BMC, switch and webhook credentials stored in the database. A database backup without the key restores everything except those credentials.
Keep .env out of the nightly backup, for example in your password manager, so that a stolen backup file alone
doesn’t reveal credentials.
Nightly database backup
Section titled “Nightly database backup”The repository contains deploy/hosts/trixos-backup. Installed as /usr/local/sbin/trixos-backup with a systemd
timer, it writes a compressed dump every night and keeps 14 days:
#!/bin/bashset -euo pipefailumask 077f=/var/backups/trixos/trixos-$(date +%F-%H%M).dumpdocker compose --project-directory /opt/trixos exec -T postgres pg_dump -U trixos -d trixos -Fc > "$f"find /var/backups/trixos -name "trixos-*.dump" -mtime +14 -deleteCopy the dumps off the host. A good pattern is a write-only target: the panel may upload but not read or delete
(for example rrsync -wo on the target), so a compromised panel can’t destroy its own backups.
Restore
Section titled “Restore”cd /opt/trixosdocker compose stop api worker poller assets viewerdocker compose exec -T postgres pg_restore -U trixos -d trixos --clean --if-exists < /var/backups/trixos/<file>.dumpdocker compose up -dUse the .env (master key) that belonged to the installation the dump came from.
Test your backups
Section titled “Test your backups”Restore the newest dump into a scratch database every few months and open the panel against it. A backup you haven’t restored is a guess.