Backup Overview
Bitwarden Server stores all critical data in a SQL Server database (or PostgreSQL/MySQL for alternative deployments). Your backup strategy should account for:- Vault data (ciphers, collections, organizations)
- User accounts and authentication data
- Organizational configurations
- Attachments and Send files (stored separately)
- Event logs and audit data
SQL Server Backups
Automated Backup Script
Bitwarden provides an automated backup script for SQL Server deployments: Location:util/MsSql/backup-db.sql and util/MsSql/backup-db.sh
Backup Script Overview:
Backup Schedule
The backup script runs automatically with configurable intervals:Configuration
Environment Variables:BACKUP_INTERVAL- When to run next backup (default:next day)BACKUP_INTERVAL_FORMAT- Date format for scheduling (default:%Y-%m-%d 00:00:00)SA_PASSWORD- SQL Server admin password
Manual Backup
Create an immediate backup:Backup Location
Default backup directory:/etc/bitwarden/mssql/backups/
Backup Filename Format:
Database Restore Procedures
SQL Server Restore
1
Stop Bitwarden Services
Stop all services to prevent data corruption:
2
Access SQL Server
Connect to the SQL Server container:
3
Restore Database
Execute the restore command:
4
Verify Restore
Check database integrity:
5
Restart Services
Start Bitwarden services:
Point-in-Time Recovery
For point-in-time recovery, you need transaction log backups:File Storage Backups
Attachment Storage
Backup attachment files separately from the database:Send Files
Backup Send file storage:Complete Backup Strategy
Create a comprehensive backup script:Migration and Upgrade Backups
Before performing migrations or upgrades:1
Create Pre-Migration Backup
Always create a backup before migrations:
2
Verify Backup Integrity
Test the backup can be restored:
3
Run Migration
Execute database migrations (see
util/Migrator/DbMigrator.cs:31):4
Verify Migration
Check migration success:
Database Migration System
Bitwarden uses DbUp for database migrations with automatic retry logic: Key Features:- Automatic database creation if missing
- Transaction-wrapped migrations
- Script versioning and tracking
- Retry logic for script upgrade mode
- 5-minute timeout per script
Offsite Backup Storage
Cloud Storage Options
AWS S3:Backup Encryption
Encrypt backups before offsite storage:Disaster Recovery
Recovery Time Objective (RTO)
Typical restoration times:- Small deployment (less than 1000 users): 15-30 minutes
- Medium deployment (1000-10000 users): 30-60 minutes
- Large deployment (more than 10000 users): 1-2 hours
Recovery Point Objective (RPO)
Recommended backup frequency:- Database: Daily full, hourly transaction logs
- Files: Daily incremental, weekly full
- Configuration: After each change
Disaster Recovery Checklist
1
Assess Damage
Determine scope of data loss and last known good backup.
2
Provision Infrastructure
Deploy new servers or repair existing infrastructure.
3
Restore Database
Restore database from most recent backup.
4
Restore Files
Restore attachment and Send file storage.
5
Restore Configuration
Apply configuration files and environment variables.
6
Verify Functionality
Test critical functions: login, vault access, sharing.
7
Resume Operations
Update DNS and redirect traffic to restored environment.
8
Post-Incident Review
Document incident and improve backup/recovery procedures.
Backup Monitoring
Verify Backup Success
Automated Alerts
Configure monitoring alerts for:- Backup failures
- Disk space issues in backup directory
- Backup files not transferred to offsite storage
- Backup age exceeding 24 hours
Best Practices
3-2-1 Rule
Maintain 3 copies of data, on 2 different media types, with 1 copy offsite.
Test Restores
Regularly test restore procedures (monthly recommended). Untested backups are not backups.
Encrypt Backups
Encrypt all backups, especially those stored offsite or in cloud storage.
Monitor Storage
Alert when backup storage exceeds 80% capacity to prevent failures.