This document defines disaster recovery procedures, failure recovery objectives, and manual fallback steps for Aegis.
Status: the recovery time objectives below are targets, not measurements. Restart recovery (apps restored after a daemon restart) is tested in CI (see
chaos_testing.md). Backup and restore are covered by unit tests (archive round trip, damaged and malicious archives, retention, an offline restore that puts back the database and key) and HTTP API tests; there is no end-to-end restore on a real server in CI yet.
| Incident Scenario | Expected Automated Behavior | Manual Recovery Protocol | Recovery Time Objective (RTO) |
|---|---|---|---|
| Daemon DB corruption or loss | The daemon fails to start or reports database errors | Restore the latest backup (section 2) | < 5 minutes |
| Server loss | – | Install Aegis on a new server with the same aegis.toml, copy a downloaded backup over and restore it (section 2) |
< 30 minutes |
| Host Reboot Mid-Deployment | Process supervisor detects interrupted deployment state on startup | Run aegis rollback or aegis deploy to reactivate prior active symlink |
< 30 seconds |
| Artifact Storage Loss | Verification stage detects missing artifact package | Re-trigger build stage via aegis deploy to re-package release artifact, or restore a backup with releases |
< 120 seconds |
| Failed Migration | Parser halts with validation error | Original systemd/PM2 configuration left untouched; run aegis validate |
< 10 seconds |
| Power Loss Outage | Daemon performs WAL log recovery on boot | Process supervisor restarts active release PIDs automatically | < 15 seconds |
These recovery times are objectives, not measurements. The only one measured so far is a clean daemon restart: in the CI soak test the daemon answered within about 120 ms of starting and the app served again right after (benchmarks.md). Power loss, reboots and restores have not been timed.
One aegis-backup-<timestamp>.tar.gz:
| Entry | Why |
|---|---|
manifest.json (first) |
Aegis version, creation time, database schema version, and every entry with its size and SHA-256 |
aegis.db |
A consistent snapshot taken with SQLite VACUUM INTO (safe while the daemon runs): events, users, tokens, sealed secrets, metrics |
secrets.key |
The key app secrets are encrypted with. Without it, restored secrets can’t be read. |
certs/ |
ACME account and certificates, so HTTPS works at once after a restore |
projects/<id>/releases/, current.json, artifacts/ |
Release directories on disk (the live one and those kept for rollback) and their metadata. Left out by “without releases” backups. |
Logs are not backed up. Archives are 0600 in a 0700 directory. They hold password hashes and the secrets key, so keep downloaded copies as carefully as the server itself.
POST /api/v1/backups with {"include_releases": false} or {}, GET /api/v1/backups, GET /api/v1/backups/{name}/download, DELETE /api/v1/backups/{name}.sudo -u aegis AEGIS_CONFIG=/etc/aegis/aegis.toml aegis-daemon admin backup [--no-releases] [--out PATH]. It prints the archive’s path.[backup] enabled = true with interval_hours or daily_at (UTC). See configuration.md.Backups in <data_dir>/backups beyond [backup] keep (default 7) are deleted, oldest first. Every backup, failure and deletion is recorded as a BackupCreated, BackupFailed or BackupDeleted event. Copy archives off the server (for example by downloading them, or with rsync from <data_dir>/backups): a backup on the same disk doesn’t help if the disk is lost.
Restores are offline. The daemon must be stopped: it holds <data_dir>/aegis.lock while it runs, and the restore also refuses if anything answers on the daemon’s gRPC or HTTP port.
sudo systemctl stop aegis
sudo -u aegis AEGIS_CONFIG=/etc/aegis/aegis.toml \
aegis-daemon admin restore /var/lib/aegis/backups/aegis-backup-20261016T033000000Z.tar.gz
sudo systemctl start aegis
(/var/lib/aegis is the data directory install.sh --server sets up. Running the restore as root also works: restored files are handed to the data directory’s owner.)
The restore:
--force is given;<data_dir>/.restore-staging-<timestamp>/, checking every entry against the manifest’s SHA-256 and refusing anything outside the layout above (absolute paths, .., symlinks leaving their release, unlisted files, hard links or devices). If anything is wrong, the staging directory is removed and nothing is changed;-wal/-shm files), secrets.key, certs/ and, if the backup has releases, artifacts/ and each project’s releases/ and current.json into <data_dir>/pre-restore-<timestamp>/;daemon.database_path may be outside the data directory). If a step fails, the moves are undone.On the next start the daemon rebuilds its state from the restored events, runs any newer migrations, and starts the apps that were running when the backup was taken. Delete pre-restore-<timestamp>/ once everything works.
Notes:
projects/<id>/logs/ are not touched.If the Aegis daemon is completely unreachable, managed application binaries remain intact in release storage directories (<data_dir>/projects/<project_id>/releases/<version>/). They can be executed directly via terminal.