Skip to main content

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.

PyPI Python Version License Downloads


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

See detailed features โ†’


What it looks like

Seven short scenes playing back-to-back โ€” doctor โ†’ dry-run โ†’ backup โ†’ history โ†’ snapshot list โ†’ restore wizard โ†’ disaster recovery. About 110 seconds end-to-end; the animation loops, so you can pause on any segment by scrolling away and back.

kopi-docka demo

Individual scenes (click to expand)
# Scene SVG
1 Doctor โ€” system health check (dependencies, repo, backend sanity, DR readiness) demo-doctor.svg
2 Dry-run โ€” plan the backup, no changes demo-dry-run.svg
3 Backup โ€” real cold backup over SFTP, two stacks in ~7s demo-backup.svg
4 History โ€” past backup runs with status, scope, snapshot IDs demo-history.svg
5 Snapshot list โ€” Kopia snapshots grouped by backup_id / type / unit tags demo-snapshot-list.svg
6 Restore wizard โ€” interactive recovery with safety-backup before overwrite demo-restore.svg
7 Disaster recovery bundle โ€” encrypted ZIP + deprecation guidance demo-dr-export.svg

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

Full installation guide โ†’

Setup

# Interactive setup wizard
sudo kopi-docka setup

The wizard guides you through:

  1. โœ… Dependency verification (Docker, Kopia)
  2. โœ… Repository storage selection (Local, S3, B2, Azure, GCS, SFTP, Tailscale, Rclone)
  3. โœ… Repository initialization
  4. โœ… Connection test

Configuration guide โ†’

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

Usage guide โ†’

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

Systemd integration โ†’


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 โ€” Linux/macOS clients)
ssh user@server "sudo kopi-docka disaster-recovery export --stream --passphrase 'xxx'" > recovery.zip
# Windows users: use cmd.exe or scp โ€” PowerShell's `>` corrupts the binary stream
# (see Disaster Recovery guide for details)

# In emergency (on new server):
1. Extract ZIP (7-Zip on Windows โ€” built-in Explorer does NOT support AES-256)
2. Run sudo ./recover.sh
3. kopi-docka restore
4. docker compose up -d

Disaster Recovery guide โ†’

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

See detailed features โ†’


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.yml files or docker run commands. 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:

  1. sudo kopi-docka restore โ†’ Restores volume data
  2. Manually recreate containers: docker compose up -d (using your original docker-compose.yml)
  3. 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.json contents 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:

๐Ÿ“ Examples:


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

Complete CLI reference โ†’


Storage Backend Options

Kopi-Docka supports 8 different storage backends:

  1. Local Filesystem - Local disk or NAS mount
  2. AWS S3 - Amazon S3 or S3-compatible (Wasabi, MinIO)
  3. Backblaze B2 - ~$6/TB/month (includes egress)
  4. Azure Blob - Microsoft Azure storage
  5. Google Cloud Storage - GCS
  6. SFTP - Remote server via SSH
  7. Tailscale - P2P over WireGuard mesh network
  8. Rclone - Universal adapter (OneDrive, Dropbox, Google Drive, 70+ services) โ€” โš ๏ธ slow on Google Drive, see issue #111

Tested Backends

End-to-end backup + restore tested by the author against real storage. Other backends are wired up and unit-tested, but I haven't run a full backup cycle against them myself โ€” community reports welcome.

Backend Status Notes
Rclone โœ… tested Live test lab. Google-Drive remote has known upstream perf limits โ€” #111
Tailscale โœ… tested NAS-over-tailnet; v7.4.0 + v7.6.1 regressions verified
SFTP โœ… tested v7.6.1 E2E: wizard โ†’ kopia repository create โ†’ full kopi-docka backup โ†’ snapshot persistence
Local Filesystem โ“ untested Should work โ€” same code path as the others, no external auth
AWS S3 โ“ untested โ€”
Backblaze B2 โ“ untested โ€”
Azure Blob โ“ untested โ€”
Google Cloud Storage โ“ untested โ€”

โš ๏ธ Performance note for rclone + Google Drive users: a known upstream limitation makes individual snapshot operations take 60-300 seconds each (Kopia marks the rclone backend as [Not maintained], Google Drive has high small-file write overhead). If you're seeing 30+ minute backups for a small amount of data, see pinned issue #111 for measurements and recommended alternatives (any of the other 7 backends will be an order of magnitude faster).

Storage configuration โ†’


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)

Detailed requirements โ†’


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

Full comparison โ†’


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:

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.

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

kopi_docka-7.6.4.tar.gz (257.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kopi_docka-7.6.4-py3-none-any.whl (294.2 kB view details)

Uploaded Python 3

File details

Details for the file kopi_docka-7.6.4.tar.gz.

File metadata

  • Download URL: kopi_docka-7.6.4.tar.gz
  • Upload date:
  • Size: 257.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for kopi_docka-7.6.4.tar.gz
Algorithm Hash digest
SHA256 da718517996904d9d5ac3c648990b7bd352a33b8c14f164a02add7368d56153a
MD5 46824ff8fe9c9c74da9848ccfe83d453
BLAKE2b-256 2ad6b50a384c4c4f4ce5525c9b568323e4c216374914985190352100c1f7124d

See more details on using hashes here.

Provenance

The following attestation bundles were made for kopi_docka-7.6.4.tar.gz:

Publisher: publish.yml on TZERO78/kopi-docka

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file kopi_docka-7.6.4-py3-none-any.whl.

File metadata

  • Download URL: kopi_docka-7.6.4-py3-none-any.whl
  • Upload date:
  • Size: 294.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for kopi_docka-7.6.4-py3-none-any.whl
Algorithm Hash digest
SHA256 86d560094b32b97856c0d489f38c825eacd3cd3843cb77c49614b0add27885ad
MD5 e6034b3bff91b470216ed4986f119858
BLAKE2b-256 696ab270573e40ef1a7a67a5c3f7ddf4b5719d69d4b46ac4cd7594f34471cef3

See more details on using hashes here.

Provenance

The following attestation bundles were made for kopi_docka-7.6.4-py3-none-any.whl:

Publisher: publish.yml on TZERO78/kopi-docka

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page