Encryption Vault
Protect your backups with AES-256-GCM encryption.
Overview
DBackup uses a two-layer encryption architecture:
- System Encryption: Protects credentials stored in the database
- Backup Encryption: Protects backup files using Encryption Profiles
How It Works
Database → Dump → Compress → Encrypt → Upload
↑
Encryption Profile KeyEach backup is encrypted with:
- Algorithm: AES-256-GCM
- Key: 256-bit from Encryption Profile
- IV: Unique random value per backup
- Auth Tag: Integrity verification
Encryption Profiles
Profiles are managed in Settings > Vault.
Create a Profile
- Go to Settings → Vault
- Click Create Profile
- Enter a descriptive name
- Click Create
The system generates a secure 256-bit key.
View Profile Key
After creation:
- Click on the profile
- Click Show Key
- Copy the 64-character hex string
Save Your Key
This key is the only way to decrypt your backups. Store it securely in a password manager!
Import a Key
To restore access after reinstallation:
- Click Import Key
- Enter a name
- Paste the 64-character hex key
- Click Import
Using Encryption
Enable on Job
- Edit a backup job
- Enable Encryption
- Select an Encryption Profile
- Save
All future backups will be encrypted.
Encrypted Backup Files
Encrypted backups have the extension .enc:
backup_2024-01-15.sql.gz.enc
backup_2024-01-15.sql.gz.enc.meta.jsonThe .meta.json file contains:
{
"encryption": {
"enabled": true,
"profileId": "uuid-of-profile",
"iv": "hex-encoded-iv",
"authTag": "hex-encoded-auth-tag"
},
"compression": "GZIP"
}System Encryption
The ENCRYPTION_KEY environment variable encrypts:
- Database passwords
- API keys and secrets
- Encryption Profile master keys
Generate Key
openssl rand -hex 32Store Securely
# .env file
ENCRYPTION_KEY=a1b2c3d4e5f6...64-characters...Critical
If you lose ENCRYPTION_KEY, you cannot decrypt stored credentials or backup keys!
Security Architecture
┌─────────────────────────────────────────┐
│ Backup File (.enc) │
│ ┌─────────────────────────────────┐ │
│ │ Encrypted with Profile Key │ │
│ └─────────────────────────────────┘ │
└─────────────────────────────────────────┘
↑
│
┌─────────────────────────────────────────┐
│ Encryption Profile (DB) │
│ ┌─────────────────────────────────┐ │
│ │ Profile Key (256-bit) │ │
│ │ Encrypted with ENCRYPTION_KEY │ │
│ └─────────────────────────────────┘ │
└─────────────────────────────────────────┘
↑
│
┌─────────────────────────────────────────┐
│ ENCRYPTION_KEY (env var) │
│ 32-byte hex string │
└─────────────────────────────────────────┘Decryption
Automatic (Restore)
When restoring through DBackup:
- System reads
.meta.json - Looks up profile by ID
- Decrypts profile key
- Decrypts backup stream
- Restores to database
Smart Key Discovery
If profile ID doesn't match (e.g., after key import):
- System tries imported keys
- Validates by checking decrypted content
- Uses matching key automatically
Manual (Recovery Kit)
If DBackup is unavailable:
- Download Recovery Kit from profile
- Use included script with backup file
- Decrypt without DBackup
Recovery Kit
Each profile can generate a Recovery Kit:
- Go to Vault
- Click profile
- Click Download Recovery Kit
The kit contains:
- Your encryption key
- Decryption script (Node.js)
- Instructions
Using the Recovery Kit
# Extract the kit
unzip recovery-kit.zip
# Decrypt a backup
node decrypt.js backup.sql.gz.enc
# Output: backup.sql.gzBest Practices
Key Management
- Generate strong keys (use built-in generator)
- Store keys in password manager (1Password, Bitwarden)
- Download Recovery Kit immediately after creation
- Test decryption before relying on backups
Multiple Profiles
Create separate profiles for:
- Different environments (prod/staging)
- Different compliance requirements
- Key rotation purposes
Regular Key Rotation
- Create new profile
- Update jobs to use new profile
- Keep old profile until old backups expire
- Delete old profile
Disaster Recovery
Prepare for worst case:
- Store keys in multiple secure locations
- Document recovery procedures
- Test restore from encrypted backup
- Keep Recovery Kit with offsite backups
Troubleshooting
Cannot Decrypt Backup
Causes:
- Wrong encryption profile
- Key was deleted
- Backup corrupted
Solutions:
- Verify correct profile ID in
.meta.json - Try importing the key again
- Use Recovery Kit if available
Profile Not Found
Cause: Profile was deleted or ID mismatch
Solutions:
- Import the key as new profile
- Smart Recovery will find matching key
- Use Recovery Kit manually
Corrupted Backup
Cause: Transfer error or storage issue
Signs:
- Auth tag verification fails
- Decryption produces garbage
Solutions:
- Re-download from storage
- Check storage integrity
- Use older backup if available
Algorithm Details
AES-256-GCM
- Block cipher: AES (Advanced Encryption Standard)
- Key size: 256 bits
- Mode: GCM (Galois/Counter Mode)
- Benefits: Authenticated encryption (confidentiality + integrity)
Why GCM?
- Detects tampering (auth tag)
- Parallelizable encryption
- No padding oracle attacks
- Industry standard
IV (Initialization Vector)
- 12 bytes (96 bits)
- Randomly generated per backup
- Stored in metadata file
- Never reused with same key
Compliance
Encryption helps meet:
- GDPR: Technical measures for data protection
- HIPAA: Encryption of PHI
- PCI-DSS: Encryption of cardholder data
- SOX: Protection of financial data
Next Steps
- Recovery Kit - Emergency decryption
- Compression - Reduce backup size
- Creating Jobs - Configure encrypted backups