Skip to content
Vaulthalla LogoVaulthalla

Backup And Recovery

Build a Vaulthalla disaster recovery set on Linux or macOS from PostgreSQL, config, state, key protection material, vault keys, internal secrets, and object storage.

Backups for Vaulthalla must cover metadata, file bodies, configuration, key protection state, and exported recovery material. A PostgreSQL dump alone is not a complete backup.

This page is about disaster recovery of a whole installation: the database, configuration, state, keys and secrets. To bring back earlier versions of individual files and folders (snapshots, local versioning, S3 provider versioning), see File Recovery. Those recovery points live on the same host or in the same bucket as the vault, so they are not a backup.

Recovery Set

A practical recovery set includes:

Item Linux macOS Why it matters
PostgreSQL database dump distribution or remote PostgreSQL the bundled cluster Users, groups, roles, vault definitions, sync policy, shares, audit state, key records, remote indexes, and metadata.
Configuration /etc/vaulthalla/config.yaml /Library/Application Support/Vaulthalla/config.yaml Runtime ports, auth settings, pricing settings, sharing settings, cache policy, and service configuration.
State /var/lib/vaulthalla /Library/Application Support/Vaulthalla/state Vaulthalla-managed state, local vault bodies, cache/index state, and sealed key material.
Key protection /var/lib/swtpm/vaulthalla when swtpm is used this Mac's Secure Enclave (not backed up; the sealed blobs are in the state directory) Unseals the master keys on the original host.
Vault key export Portable recovery material for encrypted vault content.
Recovery kit Offline, on your own computer: unwraps an S3 vault's recovery envelopes and pins its attestation keys, so the vault can be rebuilt from its bucket (Recovery Recipients). Not on the server, and not in the bucket.
Internal secret export Database and JWT secrets managed by Vaulthalla.
S3/R2 bucket data Remote object bodies for S3-compatible vaults (and, with provider versioning, their object versions).
Package version record Helps restore with the same or compatible schema and runtime behavior.
No single backup command covers everything

The current operator surfaces expose key and secret export commands, but a full backup still needs database, config, state, and object-storage backups using your normal infrastructure tooling.

Dump the database and archive configuration and state:

1sudo -u postgres pg_dump -Fc vaulthalla > vaulthalla-db.dump2# remote PostgreSQL: pg_dump -h <host> -U <user> -Fc vaulthalla > vaulthalla-db.dump3 4sudo tar -C / -czf vaulthalla-config-state.tgz \5  etc/vaulthalla \6  var/lib/vaulthalla

If using swtpm, include software TPM state:

1sudo tar -C / -czf vaulthalla-swtpm-state.tgz var/lib/swtpm/vaulthalla

Export vault keys:

1vh vault keys export all \2  --recipient <gpg-fingerprint> \3  --output vaulthalla-vault-keys.json.gpg

Export internal secrets:

1vh secret export all \2  --recipient <gpg-fingerprint> \3  --output vaulthalla-secrets.json.gpg

Record the package version:

1vh version > vaulthalla-version.txt

Local Vault Backup

For local vaults, the file bodies live in Vaulthalla-managed local state. Back up /var/lib/vaulthalla consistently with the PostgreSQL dump. Local snapshots and local versions are stored encrypted in /var/lib/vaulthalla/.vh-recovery (macOS: state/.vh-recovery) and indexed in the database, so they are only usable when both come from the same point in time. If the system is active during backup, use snapshots or a maintenance window so the database and file bodies represent a coherent point in time.

S3/R2 Vault Backup

For S3/R2 vaults, back up the bucket according to your provider's tooling. If upstream encryption is enabled, the remote object bodies still require Vaulthalla keys to decrypt.

What else you need depends on the vault's layout (vh vault info):

Vault A bucket plus Restore
Opaque storage (opaque_v1, every new encrypting S3/R2 vault) Your recovery kit (or a current key export). The bucket holds the encrypted manifest, so names, folders, trash, provider versions and snapshot records come back with it. If the server, its database and its TPM are gone: vh vault recover on a new server (Restore A Vault From Its Bucket). Users, shares, roles and other settings are not in the bucket: they come from the database backup.
Earlier layout (path_v0) PostgreSQL metadata, vault key exports, internal secrets and configuration. Restore the database first, then import the keys (Restore Vault Keys). A bucket and a kit are not enough until the vault is migrated to opaque storage (vh vault migrate-layout).

Enroll a recovery recipient on every opaque vault, pin it in your kit and keep the kit offline. A vault without a recipient or a current export is reported as degraded. Refresh the kit after a restore, and after anything you can't afford to lose to a rollback of the bucket. Keep the database backup, internal secrets and configuration as well: the bucket restores the vault's files and names, not the installation around it.

Hardware TPM Recovery

During a layout migration (Migrating A Vault To Opaque Storage) every byte stays recoverable: until the cutover the vault is still path_v0 and its database and key exports restore it as before, and after it the old path-named objects stay in the bucket for the waiting period while the opaque copies are already in place. Take a database backup and a key export (or enroll a recovery recipient) before you start; the migration refuses to start without recovery material that doesn't depend on this server. Delete nothing in the bucket by hand: the cleanup deletes exactly the versions the migration copied and verified.

Hardware TPM-sealed material is tied to the original TPM context. For host replacement, exported vault keys and internal secrets are the portable recovery material: after restoring the database on the new host, deal with the internal secrets only the old host master opened (A Lost Host Master): put the MFA keys back from their exports with vh secret set mfa-seal and vh secret set mfa-pepper (no one enrolls TOTP again), or give them up; the share-link pepper is always given up. Then vh vault keys import re-seals each vault's keys under the new host's TPM (see Restore Vault Keys). The exports' attestations stay valid there: they are checked against public keys kept in the restored database, so take exports from a current Vaulthalla (older exports carry none and can only be salvaged). Plan migration and restore testing before a hardware failure.

Software TPM Recovery

When using swtpm, restoring /var/lib/swtpm/vaulthalla can preserve the software TPM context. Protect this directory like key material. Restoring it to a different host should be treated as a sensitive security event.

macOS Key Recovery

On macOS the master keys are sealed with the Mac's Secure Enclave. Restoring the state archive to the same Mac, on the same macOS installation, brings them back: the daemon opens them on its next start under launchd.

On another Mac, or after macOS was erased and reinstalled, the sealed blobs (state/.sealed_*.blob) can't be opened, and the daemon stops at startup with an error saying so. Recover with the exports instead:

  1. After restoring the state directory, remove the old blobs: sudo sh -c 'rm -rf "/Library/Application Support/Vaulthalla/state"/.sealed_*.blob' (the state directory is private to _vaulthalla, so the pattern has to expand as root).
  2. Hand the database password to the daemon: write it to /Library/Application Support/Vaulthalla/run/db_password (owner _vaulthalla, mode 0600). The daemon seals it on its next start.
  3. Start the daemon (sudo /usr/local/lib/vaulthalla/vaulthalla-provision --apply). It creates new master keys in this Mac's Secure Enclave. A restored database holds internal secrets (MFA keys, the share-link pepper) that only the old Mac's master opens, so the daemon refuses to start until you remove them explicitly (A Lost Host Master); once it runs, import the MFA keys from their exports (vh secret set mfa-seal, vh secret set mfa-pepper --code <a recovery code of yours>) so TOTP and recovery codes keep working, or let users enroll again.
  4. Import the vault keys (vh vault keys import, see Restore Vault Keys) and set the JWT secret from the internal secret export (vh secret set jwt-secret).

Copying sealed blobs between Macs never works; only the exports move keys between machines. Installs that still use the file backend (where the Secure Enclave can't be used, or a development build) keep plaintext key files in the state directory, so there the state archive is itself key material: protect it like a key export.

Restore Outline

Use this as a cautious outline, not a blind script:

  1. Install the same Vaulthalla version where possible.

  2. Stop Vaulthalla services.

  3. Restore the configuration and state directories listed in the Recovery Set for your platform.

  4. On Linux, restore /var/lib/swtpm/vaulthalla if the backup used software TPM.

  5. Restore PostgreSQL from the dump.

  6. Reseed or verify the database password secret if the database connection changed.

  7. Start services.

  8. Run vh status and vh vault keys status all. A vault whose key shows as unavailable (the TPM or master key wasn't restored with it, or the database predates a key rotation) doesn't start, and vh status lists it; it needs its keys back: vh vault keys import <vault> --file <export>.

  9. Run vh vault sync info <vault> for S3/R2 vaults.

  10. Test read access to a known file in each vault.

  11. Open one existing share link. Share links are verified with a key sealed under the master key, like the vault keys, so they keep working only when the master key was restored too. If links fail with "share token pepper unavailable" in the log and the master key can't be recovered, start over deliberately: remove the sealed pepper and restart, which makes every existing link invalid, then create or rotate the links you still need:

    1sudo -u postgres psql vaulthalla -c "DELETE FROM internal_secrets WHERE key = 'share.token.pepper.sealed.v1'"

    Vaulthalla never replaces this key on its own.

Example service boundary:

1sudo systemctl stop vaulthalla.service vaulthalla-web.service2sudo systemctl start vaulthalla.service vaulthalla-web.service

Preserved Database Reinstall

On Linux, if the package was removed but the database was preserved, reseed the runtime database password file before restart when needed:

1sudo install -d -m 0755 /run/vaulthalla2sudo install -m 0600 -o vaulthalla -g vaulthalla /path/to/db_password /run/vaulthalla/db_password3sudo systemctl restart vaulthalla

Test Restores

Run restore drills. A backup is not proven until an operator has restored:

  • Database metadata.
  • At least one local vault file.
  • At least one S3/R2 vault file.
  • An encrypted upstream object.
  • For opaque S3/R2 vaults, a drill with vh vault recover --dry-run against the bucket and your kit, then a real restore into a scratch server, and a check that the key versions are proven rather than salvaged.
  • A user, group, role, and share record.
  • Cost-control policy state.

Document the exact Vaulthalla version, package source, database version, host TPM mode, and GPG recipient used for each recovery set.