Skip to content

Sarmkadan/docker-sqlite-backup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

docker-sqlite-backup

Reliable, scheduled SQLite backup solution for .NET.

Build License .NET

Overview

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.

Installation

git clone https://github.com/Sarmkadan/docker-sqlite-backup.git
cd docker-sqlite-backup
dotnet build

Usage

See the examples/ directory for practical usage scenarios:

Docker

You can run the application using Docker Compose:

docker-compose up -d

The 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 up

Configuration

appsettings.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>

S3 storage

{
  "S3Config": {
    "BucketName": "my-backups",
    "RegionName": "us-east-1",
    "AccessKeyId": "...",
    "SecretAccessKey": "...",
    "ObjectKeyPrefix": "sqlite/",
    "EnableServerSideEncryption": true
  }
}

Azure Blob Storage

{
  "AzureConfig": {
    "ConnectionString": "DefaultEndpointsProtocol=https;...",
    "ContainerName": "sqlite-backups",
    "BlobPrefix": "production/",
    "AccessTier": "Cool"
  }
}

Encryption

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>

Tests

dotnet test

Benchmarks

This 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

Results

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

License

MIT - Copyright (c) 2026 Vladyslav Zaiets

About

Automated SQLite backup tool for .NET - scheduled snapshots, S3/local storage, rotation, restore verification

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors