Reliable, scheduled SQLite backup solution for .NET.
docker-sqlite-backup is a background worker for .NET that performs scheduled SQLite backups. It snapshots your database on a cron schedule, and stores backups locally, or in S3/Azure. Supports AES-256 encryption, rotation, and restore verification.
git clone https://github.com/Sarmkadan/docker-sqlite-backup.git
cd docker-sqlite-backup
dotnet buildSee the examples/ directory for practical usage scenarios:
- BasicUsage.cs - Getting started
- AdvancedUsage.cs - Configuration and error handling
- IntegrationExample.cs - ASP.NET DI integration
You can run the application using Docker Compose:
docker-compose up -dThe application will be available at http://localhost:8080.
For development with hot-reload enabled:
docker-compose -f docker-compose.yml -f docker-compose.dev.yml upappsettings.json:
{
"AppSettings": {
"DatabasePath": "/data/app.db",
"MaxConcurrentBackups": 2,
"BackupTimeoutSeconds": 3600,
"ScheduleCheckIntervalSeconds": 60,
"EnableVerificationByDefault": true,
"RetentionDays": 30,
"MaxBackupCount": 10,
"LocalStoragePath": "/backups"
}
}All keys can be overridden via environment variables using double-underscore:
AppSettings__DatabasePath=/data/prod.db
AppSettings__LocalStoragePath=/var/backups/sqlite
BACKUP_ENCRYPTION_KEY=<base64-encoded-32-byte-key>{
"S3Config": {
"BucketName": "my-backups",
"RegionName": "us-east-1",
"AccessKeyId": "...",
"SecretAccessKey": "...",
"ObjectKeyPrefix": "sqlite/",
"EnableServerSideEncryption": true
}
}{
"AzureConfig": {
"ConnectionString": "DefaultEndpointsProtocol=https;...",
"ContainerName": "sqlite-backups",
"BlobPrefix": "production/",
"AccessTier": "Cool"
}
}Set AppSettings__EnableEncryption=true and provide a 32-byte Base64 key.
The key is read from BACKUP_ENCRYPTION_KEY env var first, then AppSettings.EncryptionKey.
# Generate a key
openssl rand -base64 32
export BACKUP_ENCRYPTION_KEY=<output>dotnet testThis project includes a BenchmarkDotNet suite to monitor performance of critical operations like encryption and checksum generation.
To run the benchmarks:
cd tests/docker-sqlite-backup.Benchmarks
dotnet run -c Release| Method | Mean | Error | StdDev | Allocated |
|---|---|---|---|---|
| CalculateSha256 | 9.073 ms | 0.176 ms | 0.164 ms | 1.44 KB |
| CalculateCrc32 | 53.566 ms | 1.059 ms | 1.177 ms | 109.99 KB |
| GenerateQuickChecksum | 8.441 us | 0.166 us | 0.237 us | 5.76 KB |
| Encrypt | 1.856 ms | 0.050 ms | 0.063 ms | 9.31 KB |
| Decrypt | 2.518 ms | 0.132 ms | 0.132 ms | 23.93 KB |
MIT - Copyright (c) 2026 Vladyslav Zaiets