# Restoring from backups Each host backs itself up nightly with restic (ops 03:30, services 04:15 UTC) into two independent repositories: | Name | Repository | |------|------------| | `hel1` | `s3:https://hel1.your-objectstorage.com/asxpio-backups-main/restic/` | | `fsn1` | `s3:https://fsn1.your-objectstorage.com/asxpio-backups-repl/restic/` | A snapshot holds `/etc`, `/opt`, the listed container volumes and `/var/backups/restic-stage`, where hooks put consistent copies of the databases just before the run: | Host | In `/var/backups/restic-stage` | Volumes | |------|--------------------------------|---------| | asxpio-ops | `pg_dumpall.sql`, `asxpio.dump` (`pg_dump -Fc`), `forgejo-gitea.db` | `storage_garage_meta`, `storage_garage_data` (with a fresh Garage metadata snapshot) | | asxpio-services | `ejabberd.sqlite`; ejabberd's Mnesia as `nightly.backup` inside `xmpp_database` | `xmpp_database`, `xmpp_tackygram` | Not in the backup: Postgres' data directory (restore from the dump), `/opt/containerd`, and what Minecraft downloads again (`cache`, `libraries`, `versions`). The exact lists are `restic_paths`, `restic_excludes` and `restic_pre_hooks` in `ansible/inventory/host_vars/`. Three secrets are needed, and none of them may exist only on the servers: the Object Storage access key and secret key, and the restic password (`vault_restic_password` in the Ansible vault). **Without the password nothing can be read.** ## One file or one service, on a running host ```sh restic-backup hel1 snapshots restic-backup hel1 ls latest /opt/xmpp restic-backup fsn1 restore latest --target /tmp/r --include /opt/xmpp ``` Restore beside the live data, compare, then stop the service and move the files into place. ## A whole host, onto a fresh system On a host built by `nixos/README.md` (or any Linux with restic): ```sh export AWS_ACCESS_KEY_ID=... AWS_SECRET_ACCESS_KEY=... export RESTIC_PASSWORD=... export RESTIC_REPOSITORY=s3:https://hel1.your-objectstorage.com/asxpio-backups-main/restic/asxpio-ops restic snapshots --host asxpio-ops # pick one; "latest" below ``` Keep every service stopped until its data is back, so nothing starts on an empty directory and creates fresh state where the restore will land. 1. **Files.** `/etc` is restored aside, for reference only: the system's configuration comes from the flake. ```sh restic restore latest --target / --include /opt --include /var/backups/restic-stage restic restore latest --target /root/restored-etc --include /etc ``` 2. **Volumes** (while services still run in containers): create each volume, then restore into it. ```sh docker volume create storage_garage_meta # one per volume in the table restic restore latest --target / --include /var/lib/docker/volumes/storage_garage_meta ``` Under Podman the volume lives in `/var/lib/containers/storage/volumes/`: restore to a temporary target and move `_data` there. 3. **Databases**, from the staged copies rather than the live files: - **Postgres** (ops): start Postgres alone on its empty data directory, then load everything, roles included: ```sh psql -U postgres -f /var/backups/restic-stage/pg_dumpall.sql ``` `asxpio.dump` is the same database in `pg_restore` format, for restoring only that one. - **Forgejo** (ops): `cp /var/backups/restic-stage/forgejo-gitea.db /opt/forgejo/data/gitea/gitea.db`, owner as the file it replaces. - **Garage** (ops): if it does not start on the restored metadata, use the snapshot inside the metadata volume (`snapshots/`), as described in Garage's [recovery documentation](https://garagehq.deuxfleurs.fr/documentation/operations/recovering/). - **ejabberd** (services): replace `ejabberd.sqlite` in `xmpp_database` with the staged copy; if Mnesia does not come up clean, `ejabberdctl restore /opt/ejabberd/database/nightly.backup`. 4. **Start the services**, then check: the sites answer, a `git clone` from Forgejo works, an XMPP client logs in, the Minecraft world is the expected one, and the next nightly backup succeeds. The app stacks on ops (asxpio, datacenterbingo, blog, czsk, vhpbot, storage) come back with `/opt/` (compose file and `.env`); their images are pulled from the registry in Forgejo, so Forgejo and storage come first. If the registry copy is gone, re-run each app's CI. ## Onto a NixOS host The backup made by a NixOS host holds the new layout (`/var/lib/forgejo`, `/var/lib/garage`, `/var/lib/minecraft`, ...): restore to `/`, load the Postgres dump, `touch /var/lib/.data-in-place`, start the services. A backup made while the host was still Debian holds the layout described above. Restore it to a side directory and let the migration script move it into place; this is what was rehearsed on 2026-11-16: ```sh restic restore latest --host asxpio-ops --target /restore bash nixos/migration/ops-data.sh /restore # or services-data.sh ``` ## Keeping this true A restore that was never tried is a hope. After any change to what is backed up, and at least twice a year, restore the latest snapshot of each host onto a rehearsal server (`nixos/README.md`) and walk through this page. Last walk-through: 2026-11-16, both hosts, onto the NixOS rehearsal pair (Traefik, monitoring, the app stacks and XMPP not yet part of it).