DEV Community

William Rodriguez
William Rodriguez

Posted on

Disaster recovery: Encrypted backups and cross-machine restores.

Disaster recovery: Encrypted backups and cross-machine restores.

Exporting a database backup shouldn't mean leaving all your API tokens in a plaintext SQL dump. wauth's backup() and restore() primitives ensure snapshots remain fully encrypted during storage and migration.

Here is the exact production implementation for Encrypted Backup & Disaster Recovery:

from wauth import WAuth

# Machine A: Export encrypted snapshot
auth_prod = WAuth(db_path="prod.db", custom_key="migration-passphrase-991")
auth_prod.set("API_TOKEN", "sk_live_12345")
auth_prod.backup("prod_backup.wauth")
print("Encrypted snapshot exported safely.")

# Machine B: Restore from encrypted snapshot using the same passphrase
auth_dr = WAuth(db_path="dr.db", custom_key="migration-passphrase-991")
restored_count = auth_dr.restore("prod_backup.wauth")
print(f"Restored {restored_count} secrets on disaster recovery node!")
Enter fullscreen mode Exit fullscreen mode

Why this changes developer velocity:

  • Encrypted Vault Snapshots: auth.backup('vault.wauth') exports secrets in encrypted form.
  • Deterministic Restores: auth.restore('vault.wauth') imports snapshots and returns restored count.
  • Cross-Machine Portability: Pair with custom_key to migrate vaults securely between nodes.

Zero Pain:

  • Database backups exposing sensitive secrets in unencrypted SQL dump text files
  • Complicated manual recovery procedures when provisioning a replacement node
  • Lack of tamper-evident snapshot formats for compliance and audit archiving

Explore the verified open-source repository on GitHub or install it via:

pip install wauth
Enter fullscreen mode Exit fullscreen mode

Top comments (0)