Disaster Recovery
Disaster Recovery
Section titled “Disaster Recovery”This guide covers recovering a Mantis deployment from catastrophic failure, including complete data loss, infrastructure failure, and key compromise scenarios.
Recovery Requirements
Section titled “Recovery Requirements”To fully recover a Mantis deployment, you need three things:
| Component | Source | Why It Is Needed |
|---|---|---|
| Database backup | pg_dump or cloud snapshot | All configuration, deployment history, audit logs |
| Encryption master key | Secrets manager or offline backup | Decrypt credentials, secrets, and sensitive variables |
| TLS certificates and CA key | Certificate backup | Re-establish mTLS trust between components |
Recovery Scenarios
Section titled “Recovery Scenarios”Scenario 1: Single Component Failure
Section titled “Scenario 1: Single Component Failure”Impact: One Mantis component (Mandible, Thorax, or Tarsus) is lost.
Recovery:
- Re-install the component on the same or new host
- Restore the component’s TLS certificate and key from backup
- Update configuration to point to existing infrastructure (database, RabbitMQ)
- Start the component
# Example: Restore and restart Mandiblecp /opt/mantis/backups/certs/mandible.* /etc/mantis/certs/cp /opt/mantis/backups/config/mandible.toml /etc/mantis/
# Set the encryption keyexport MANTIS_ENCRYPTION_KEY="$(vault kv get -field=key secret/mantis/encryption)"
systemctl start mandible
# Verify healthcurl -s https://localhost:3000/api/v1/health | jqThe database and other components are unaffected. Thorax and Tarsus will reconnect automatically.
Scenario 2: Database Loss
Section titled “Scenario 2: Database Loss”Impact: PostgreSQL data is lost. All configuration, deployment history, and audit logs are gone.
Recovery:
- Provision a new PostgreSQL instance
- Restore from the latest database backup
- Verify the encryption master key matches the backup
- Restart all Mantis components
# Provision new databasecreatedb -h new-db-host -U postgres mantis
# Restore from backuppg_restore -h new-db-host -U mantis -d mantis \ /opt/mantis/backups/db/mantis-latest.dump
# Update Mandible configurationexport MANDIBLE__DATABASE__URL="postgres://mantis:password@new-db-host:5432/mantis"
# Restart servicessystemctl restart mandibleData loss window: From the time of the last backup to the time of failure. Consider enabling PostgreSQL WAL archiving for point-in-time recovery to minimize this window.
Scenario 3: Complete Infrastructure Loss
Section titled “Scenario 3: Complete Infrastructure Loss”Impact: All servers, databases, and services are lost (data center failure).
Recovery procedure:
- Provision infrastructure — Set up new servers, PostgreSQL, RabbitMQ, and Redis (Redis is required — JWT revocation fails closed and SSE is non-functional without it)
- Restore certificates — Extract from encrypted off-site backup
- Restore database — Restore from off-site backup or cloud snapshot
- Deploy components — Install Mandible, Thorax, and Tarsus
- Configure and start — Apply configuration with correct endpoints
- Re-register agents — Tarsus agents may need to re-register
# Step 1: Infrastructure# (Provision via Terraform, CloudFormation, or manually)
# Step 2: Restore certificatesgpg --decrypt /offsite/certs-backup.tar.gz.gpg | tar xzf - -C /etc/mantis/
# Step 3: Restore databasepg_restore -h localhost -U mantis -d mantis /offsite/mantis-latest.dump
# Step 4-5: Deploy and configure# (Use your standard deployment procedure)
# Step 6: Verifycurl -s https://new-mandible:3000/api/v1/health | jq# /health/grpc returns the overall status to any caller; pass a token to also# see the breaker internals (circuit_state, failure_count), which anonymous# requests do not receive.curl -s -H "Authorization: Bearer $TOKEN" \ https://new-mandible:3000/api/v1/health/grpc | jqScenario 4: Encryption Key Compromise
Section titled “Scenario 4: Encryption Key Compromise”Impact: The encryption master key has been exposed to an unauthorized party.
Immediate actions:
- Rotate the master key immediately
- Re-encrypt all data with the new key
- Rotate all credentials that may have been decrypted
- Review audit logs for unauthorized access
# Generate new master keyNEW_KEY=$(openssl rand -base64 32)
# Rotate encryption key (re-encrypts all data)mantisctl key rotate --old-key "$OLD_KEY" --new-key "$NEW_KEY"
# Update the key in your secrets managervault kv put secret/mantis/encryption key="$NEW_KEY"
# Restart services with new keyexport MANTIS_ENCRYPTION_KEY="$NEW_KEY"systemctl restart mandible thoraxScenario 5: CA Key Compromise
Section titled “Scenario 5: CA Key Compromise”Impact: An attacker can sign certificates for any component.
Immediate actions:
- Generate a new CA key pair
- Re-sign all component certificates with the new CA
- Distribute new certificates to all components
- Revoke the old CA certificate
- Restart all services
This is the most disruptive recovery scenario. Plan and practice this procedure in advance.
Recovery Time Objectives
Section titled “Recovery Time Objectives”| Scenario | Expected RTO | Depends On |
|---|---|---|
| Single component failure | 15-30 minutes | Backup availability, deployment automation |
| Database loss | 30-60 minutes | Backup size, restore speed |
| Complete infrastructure loss | 2-4 hours | Infrastructure provisioning, backup retrieval |
| Key compromise | 1-2 hours | Re-encryption time, credential rotation scope |
Recovery Testing
Section titled “Recovery Testing”Test your recovery procedures regularly:
Monthly: Backup Verification
Section titled “Monthly: Backup Verification”# Restore database to temporary instance and verifycreatedb mantis_dr_testpg_restore -d mantis_dr_test /opt/mantis/backups/db/mantis-latest.dumppsql -d mantis_dr_test -c "SELECT count(*) FROM tenants"dropdb mantis_dr_testQuarterly: Full Recovery Drill
Section titled “Quarterly: Full Recovery Drill”- Provision isolated test infrastructure
- Restore all backups (database, certificates, configuration)
- Start all components
- Verify deployments can be created and executed
- Document any issues encountered
- Update procedures based on findings
Prevention Checklist
Section titled “Prevention Checklist”- Daily database backups with off-site copies
- Weekly certificate backup verification
- Encryption master key stored in secrets manager with backup
- CA key stored offline or in HSM
- WAL archiving enabled for point-in-time recovery
- Recovery procedures documented and tested quarterly
- Alert on backup job failures
- Backup retention meets compliance requirements
Next Steps
Section titled “Next Steps”- Database Backup — Database backup procedures
- Certificate Backup — Certificate backup procedures
- Key Rotation Runbook — Scheduled rotation procedures
- Encryption at Rest — Master key management
