Robust cold backups for Docker environments using Kopia
Project description
Kopi-Docka
Cold Backup Tool for Docker Environments using Kopia
Kopi-Docka is a Python-based backup wrapper for Docker containers and volumes. It uses Kopia for encryption and deduplication, with specific focus on Docker Compose stack awareness.
What is Kopi-Docka?
Kopi-Docka = Kopia + Docker + Backup
A wrapper around Kopia, designed for Docker environments:
- ๐ฆ Stack-Aware - Recognizes Docker Compose stacks and backs them up as logical units
- ๐ Encrypted - End-to-end encryption via Kopia (AES-256-GCM)
- ๐ Multiple Storage Options - Local, S3, B2, Azure, GCS, SFTP, Tailscale, Rclone
- ๐พ Disaster Recovery - Encrypted bundles with auto-reconnect scripts
- ๐ง Pre/Post Hooks - Custom scripts (maintenance mode, notifications, etc.)
- ๐ Systemd Integration - Daemon with sd_notify and watchdog support
- ๐ Restore on New Hardware - Recovery without original system
- ๐ก๏ธ Graceful Shutdown - SafeExitManager ensures containers restart after Ctrl+C
- ๐ Notifications - Telegram, Discord, Email alerts via Apprise
Quick Start
Prerequisites
Kopi-Docka expects a prepared system. You need to install dependencies before installing Kopi-Docka:
Required:
Quick check:
docker --version
kopia --version
Need automated setup? Use Server-Baukasten for automated system preparation.
Installation
# Recommended: pipx (isolated environment)
pipx install kopi-docka
# Make available for sudo (pipx installs to ~/.local/bin)
sudo ln -s ~/.local/bin/kopi-docka /usr/local/bin/kopi-docka
# Or: pip (system-wide)
pip install kopi-docka
# Verify all dependencies
kopi-docka doctor
Setup
# Interactive setup wizard
sudo kopi-docka setup
The wizard guides you through:
- โ Dependency verification (Docker, Kopia)
- โ Repository storage selection (Local, S3, B2, Azure, GCS, SFTP, Tailscale, Rclone)
- โ Repository initialization
- โ Connection test
First Backup
# System health check
sudo kopi-docka doctor
# List backup units (containers/stacks)
sudo kopi-docka advanced snapshot list
# Test run (no changes)
sudo kopi-docka dry-run
# Full backup
sudo kopi-docka backup
# Create disaster recovery bundle (encrypted ZIP)
sudo kopi-docka disaster-recovery export ~/recovery.zip
# โ Store bundle + passphrase off-site: USB/cloud/safe
Automatic Backups
# Generate systemd units
sudo kopi-docka advanced service write-units
# Enable daily backups (02:00 default)
sudo systemctl enable --now kopi-docka.timer
# Check status
sudo systemctl status kopi-docka.timer
# Or use the interactive management wizard
sudo kopi-docka advanced service manage
Key Features
1. Compose-Stack-Awareness
Recognizes Docker Compose stacks and backs them up as atomic units with docker-compose.yml included.
Traditional vs. Kopi-Docka:
Traditional: Kopi-Docka:
โโโ wordpress_web_1 Stack: wordpress
โโโ wordpress_db_1 โโโ Containers: web, db, redis
โโโ wordpress_redis_1 โโโ Volumes: wordpress_data, mysql_data
โโโ docker-compose.yml
โ Context lost โโโ Common backup_id
โ
Complete stack restorable
2. Disaster Recovery Bundles
Single encrypted ZIP files containing repository connection data, configuration, and auto-reconnect scripts:
# Create encrypted ZIP bundle (recommended, v6.2.0+)
sudo kopi-docka disaster-recovery export ~/recovery.zip
# Or stream via SSH (zero disk footprint on server)
ssh user@server "sudo kopi-docka disaster-recovery export --stream --passphrase 'xxx'" > recovery.zip
# In emergency (on new server):
1. Extract ZIP (7-Zip, unzip, WinZip)
2. Run sudo ./recover.sh
3. kopi-docka restore
4. docker compose up -d
3. Tailscale Integration
Automatic peer discovery for P2P backups over WireGuard mesh network:
sudo kopi-docka advanced config new
# โ Select Tailscale
# โ Shows all devices in your Tailnet
# โ Auto-configures SSH keys
# โ Direct encrypted connection (no cloud costs)
4. Systemd Integration
Daemon implementation with:
- sd_notify status reporting
- Watchdog monitoring
- Security hardening (ProtectSystem, NoNewPrivileges, etc.)
- PID locking (prevents parallel runs)
- Structured logging to systemd journal
Backup Scopes
Kopi-Docka supports three backup scopes to balance speed, size, and restore capabilities:
Scope Comparison
| Scope | What's Backed Up | Restore Capability | Use Case |
|---|---|---|---|
| minimal | โ Volumes only | โ ๏ธ Data only - containers must be manually recreated | Fastest backups when you always have docker-compose files available |
| standard | โ
Volumes โ Recipes (docker-compose.yml) โ Networks (IPAM config) |
โ Full container restore | Recommended - Complete restore capability |
| full | โ
Volumes โ Recipes โ Networks โ Docker daemon config |
โ Full restore + manual daemon config | Disaster recovery with Docker daemon settings |
Detailed Restore Matrix
| Scope | Volumes | Container Configs | Networks | Docker Daemon Config |
|---|---|---|---|---|
| minimal | โ Restored | โ Not backed up* | โ Not backed up | โ Not backed up |
| standard | โ Restored | โ Restored | โ Restored | โ Not backed up |
| full | โ Restored | โ Restored | โ Restored | โ ๏ธ Manual restore** |
Notes:
- * Minimal scope limitation: Only volume data is backed up. After restore, you must manually recreate containers using your original
docker-compose.ymlfiles ordocker runcommands. Networks must also be manually recreated. - ** Docker config safety: Docker daemon configuration (
/etc/docker/daemon.json, systemd overrides) is backed up but not automatically restored. This prevents accidental production breakage. Review and manually apply configuration changes.
Usage Examples
Set default scope in config wizard:
sudo kopi-docka advanced config new
# โ Interactive menu will prompt for scope selection
# โ Default: standard (recommended)
Set scope in config file:
{
"backup": {
"backup_scope": "standard"
}
}
Override scope via CLI flag:
# Minimal - Fastest, smallest backups (volumes only)
sudo kopi-docka backup --scope minimal
# Standard - Recommended (volumes + recipes + networks)
sudo kopi-docka backup --scope standard
# Full - Complete DR including Docker daemon config
sudo kopi-docka backup --scope full
โ ๏ธ Minimal Scope Warning
If you restore from a minimal scope backup, Kopi-Docka will show a prominent warning:
โ ๏ธ MINIMAL Scope Backup Detected
This backup contains ONLY volume data.
Container recipes (docker-compose files) are NOT included.
After restore:
โข Volumes will be restored
โข Containers must be recreated manually
โข Networks must be recreated manually
Consider using --scope standard or --scope full for complete backups.
Recovery steps for minimal scope backups:
sudo kopi-docka restoreโ Restores volume data- Manually recreate containers:
docker compose up -d(using your original docker-compose.yml) - Manually recreate networks if needed:
docker network create ...
๐ง Docker Config Manual Restore
For FULL scope backups, Docker daemon configuration is backed up but requires manual restoration:
Extract docker_config snapshot:
# List docker_config snapshots
sudo kopi-docka list --snapshots | grep docker_config
# Extract configuration to temp directory
sudo kopi-docka show-docker-config <snapshot-id>
What this command does:
- Extracts docker_config snapshot to
/tmp/kopia-docker-config-XXXXX/ - Displays safety warnings about manual restore
- Shows extracted files (
daemon.json, systemd overrides) - Displays
daemon.jsoncontents inline (if <10KB) - Provides 6-step manual restore instructions
Why manual restore?
- Docker daemon configuration is extremely sensitive
- Incorrect config can break Docker entirely
- Must be reviewed before applying to production
- Prevents accidental system breakage
Example output:
โ Extracted files:
โข daemon.json (2.3 KB)
โข docker.service.d/override.conf (0.5 KB)
๐ daemon.json contents:
{
"log-driver": "json-file",
"log-opts": {
"max-size": "10m",
"max-file": "3"
}
}
๐ง Manual Restore Instructions
Step 1: Review extracted files
Step 2: Backup current config
Step 3: Apply configuration (CAREFULLY!)
Step 4: Systemd overrides (if present)
Step 5: Restart Docker daemon
Step 6: Verify Docker is working
Scope Selection Guidance
Choose minimal when:
- You need fastest possible backups
- You always have access to original docker-compose files
- You're comfortable manually recreating containers after restore
- Storage space is extremely limited
Choose standard when (RECOMMENDED):
- You want complete restore capability
- You prefer automated container recreation
- You want network configurations preserved
- You need reliable disaster recovery
Choose full when:
- You need complete disaster recovery capability
- You have custom Docker daemon configuration
- You use systemd service overrides for Docker
- You want to preserve all Docker settings
Default: standard (best balance for most users)
Documentation
๐ Guides:
- Installation - System requirements, installation options
- Configuration - Wizards, config files, storage backends
- Usage - CLI commands, workflows, how it works
- Features - Detailed feature documentation
- Disaster Recovery - DR bundles, recovery workflow, SSH streaming
- Hooks - Pre/post backup hooks, examples
- Troubleshooting - Common issues, FAQ
- Development - Project structure, contributing
- Architecture - Code-driven architecture overview (authoritative)
๐ Examples:
- examples/config.json - Sample configuration
- examples/docker-compose.yml - Example stack
- examples/hooks/ - Hook script examples
- examples/systemd/ - Systemd setup guide
CLI Commands
Kopi-Docka features a simplified CLI with top-level commands and an admin subcommand for advanced operations.
Top-Level Commands
sudo kopi-docka setup # Complete setup wizard
sudo kopi-docka backup # Full backup (standard scope)
sudo kopi-docka restore # Interactive restore wizard
sudo kopi-docka restore --yes # Non-interactive restore (CI/CD)
sudo kopi-docka show-docker-config <snapshot-id> # Extract docker_config for manual restore
sudo kopi-docka disaster-recovery export ~/recovery.zip # Create DR bundle (ZIP)
sudo kopi-docka dry-run # Simulate backup (preview)
sudo kopi-docka doctor # System health check
kopi-docka version # Show version
Admin Commands
# Configuration
sudo kopi-docka advanced config show # Show config
sudo kopi-docka advanced config new # Create new config
sudo kopi-docka advanced config edit # Edit config
# Repository
sudo kopi-docka advanced repo init # Initialize repository
sudo kopi-docka advanced repo status # Repository info
# Snapshots & Units
sudo kopi-docka advanced snapshot list # List backup units
sudo kopi-docka advanced snapshot list --snapshots # List all snapshots
sudo kopi-docka advanced snapshot estimate-size # Estimate backup size
sudo kopi-docka advanced snapshot manage # Interactive management wizard
sudo kopi-docka advanced snapshot delete <id> # Delete a snapshot
sudo kopi-docka advanced snapshot pin <id> # Pin snapshot (protect from cleanup)
sudo kopi-docka advanced snapshot unpin <id> # Unpin snapshot
sudo kopi-docka advanced snapshot maintenance # Run maintenance
sudo kopi-docka advanced snapshot prune-empty # Expire snapshots (apply retention)
sudo kopi-docka advanced snapshot retention show # Show retention policy
sudo kopi-docka advanced snapshot retention set \
--latest 10 --daily 7 --weekly 4 --monthly 12 # Update retention policy
# System & Service
sudo kopi-docka advanced system install-deps # Install dependencies
sudo kopi-docka advanced service write-units # Generate systemd units
sudo kopi-docka advanced service daemon # Run as daemon
Storage Backend Options
Kopi-Docka supports 8 different storage backends:
- Local Filesystem - Local disk or NAS mount
- AWS S3 - Amazon S3 or S3-compatible (Wasabi, MinIO)
- Backblaze B2 - ~$6/TB/month (includes egress)
- Azure Blob - Microsoft Azure storage
- Google Cloud Storage - GCS
- SFTP - Remote server via SSH
- Tailscale - P2P over WireGuard mesh network
- Rclone - Universal adapter (OneDrive, Dropbox, Google Drive, 70+ services)
System Requirements
- OS: Linux (Debian, Ubuntu, Arch, Fedora, RHEL/CentOS)
- Python: 3.10 or newer
- Docker: Docker Engine 20.10+
- Kopia: >= 0.13 (recommended; required for sparse-file support) (automatically checked)
Feature Comparison
| Feature | Kopi-Docka | docker-volume-backup | Duplicati | Restic |
|---|---|---|---|---|
| Docker-native | โ | โ | โ | โ |
| Cold Backups | โ | โ | โ | โ |
| Compose-Stack-Aware | โ | โ | โ | โ |
| Network Backup* | โ | โ | โ | โ |
| DR Bundles | โ | โ | โ | โ |
| Tailscale Integration | โ | โ | โ | โ |
| Rclone Support | โ | โ | โ | โ |
| systemd Integration | โ | โ | โ | โ |
| Pre/Post Hooks | โ | โ ๏ธ | โ | โ |
| Storage Options | 8 backends | Basic | Many | Many |
| Deduplication | โ (Kopia) | โ | โ | โ |
*Network Backup = Automatic backup of custom Docker networks with IPAM configuration (subnets, gateways)
Kopi-Docka's focus: Stack-awareness, disaster recovery bundles, Tailscale P2P, and systemd hardening
Project Status
Status: Feature-Complete, Stabilization Phase
Latest Release: See badges above โ
The current release includes all planned core features:
- โ Backup scope selection (minimal/standard/full)
- โ Docker network backup with IPAM
- โ Pre/Post backup hooks
- โ Disaster recovery bundles
- โ Systemd integration with hardening
Current Focus:
- Bug fixing and edge-case handling
- Test coverage expansion
- Documentation improvements
Known Limitations:
- Single repository only (no parallel multi-cloud backup)
- Hooks require careful configuration (Safety Guide)
- Restore edge-cases still being hardened
New major features: Only after stable foundation
View Changelog | Development Roadmap
Thanks & Acknowledgments
Kopi-Docka = Kopia + Dockar โ the name reflects what this project is: a bridge between two excellent tools.
Kopi-Docka would not exist without these excellent tools:
-
Kopia โ the rock-solid backup engine providing encryption, deduplication and snapshot management
https://kopia.io -
Docker โ container runtime and ecosystem that makes reproducible environments possible
https://www.docker.com -
Tailscale โ secure WireGuard-based networking that enables simple peer-to-peer offsite backups
https://tailscale.com -
rclone โ universal storage adapter enabling access to many affordable cloud and remote storage providers
https://rclone.org -
Typer โ clean and readable CLI framework for Python https://typer.tiangolo.com
-
Pydantic โ data validation and settings management using Python type annotations https://docs.pydantic.dev
-
Apprise โ universal notification library supporting 100+ services https://github.com/caronc/apprise
All of these tools remain under their respective licenses and are not bundled with Kopi-Docka.
This project is built with deep respect for the open-source ecosystem.
Author: Markus F. (TZERO78)
Links: PyPI | GitHub
License
MIT License - see LICENSE for details.
Copyright (c) 2025 Markus F. (TZERO78)
Feedback & Support
If you find Kopi-Docka useful, feel free to leave a โญ on GitHub.
I cannot test all storage backends and edge cases on my own, so feedback from real-world setups is highly appreciated.
If something doesn't work as expected, please open an Issue and include your environment details.
- ๐ฆ PyPI: pypi.org/project/kopi-docka
- ๐ Documentation: Complete docs
- ๐ Bug Reports: GitHub Issues
- ๐ฌ Discussions: GitHub Discussions
- ๐งโ๐คโ๐ง Code of Conduct: CODE_OF_CONDUCT.md
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kopi_docka-7.0.2.tar.gz.
File metadata
- Download URL: kopi_docka-7.0.2.tar.gz
- Upload date:
- Size: 217.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7c62b9fe5871f32070f5d41241b2029bd608ab8791b3bd0f1c1ec6372766644
|
|
| MD5 |
edfe9760092b1538571c5e07bc4af151
|
|
| BLAKE2b-256 |
068697976f0ffcd30fe42f0d8da3e43467c1657ff699894edead23ecfe268f34
|
Provenance
The following attestation bundles were made for kopi_docka-7.0.2.tar.gz:
Publisher:
publish.yml on TZERO78/kopi-docka
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kopi_docka-7.0.2.tar.gz -
Subject digest:
a7c62b9fe5871f32070f5d41241b2029bd608ab8791b3bd0f1c1ec6372766644 - Sigstore transparency entry: 1293660259
- Sigstore integration time:
-
Permalink:
TZERO78/kopi-docka@cdaee304d275636f6222593f1612bead39294ef5 -
Branch / Tag:
refs/tags/v7.0.2 - Owner: https://github.com/TZERO78
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@cdaee304d275636f6222593f1612bead39294ef5 -
Trigger Event:
push
-
Statement type:
File details
Details for the file kopi_docka-7.0.2-py3-none-any.whl.
File metadata
- Download URL: kopi_docka-7.0.2-py3-none-any.whl
- Upload date:
- Size: 252.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d50ff430704561de5248ca64ce8667a177ecf7735968b4f55f7fe5de50be7674
|
|
| MD5 |
c9779dd0dabf12298b93c032afc204e1
|
|
| BLAKE2b-256 |
6b458d14108930df5425615d28461c5a02246dc30ea16041ef6ca644a0167949
|
Provenance
The following attestation bundles were made for kopi_docka-7.0.2-py3-none-any.whl:
Publisher:
publish.yml on TZERO78/kopi-docka
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kopi_docka-7.0.2-py3-none-any.whl -
Subject digest:
d50ff430704561de5248ca64ce8667a177ecf7735968b4f55f7fe5de50be7674 - Sigstore transparency entry: 1293660266
- Sigstore integration time:
-
Permalink:
TZERO78/kopi-docka@cdaee304d275636f6222593f1612bead39294ef5 -
Branch / Tag:
refs/tags/v7.0.2 - Owner: https://github.com/TZERO78
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@cdaee304d275636f6222593f1612bead39294ef5 -
Trigger Event:
push
-
Statement type: