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

See detailed features โ†’


Quick Start

Installation

# Recommended: pipx (isolated environment)
pipx install kopi-docka

# Or: pip (system-wide)
pip install kopi-docka

Full installation guide โ†’

Setup

# Interactive setup wizard
sudo kopi-docka setup

The wizard guides you through:

  1. โœ… Dependency check (Kopia, Docker)
  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
sudo kopi-docka disaster-recovery
# โ†’ Store bundle 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

Encrypted packages containing repository connection data and auto-reconnect scripts:

# Create bundle
sudo kopi-docka disaster-recovery

# In emergency (on new server):
1. Decrypt bundle
2. Run ./recover.sh
3. kopi-docka restore
4. docker compose up -d

Note: The legacy TAR/stdin snapshot method is deprecated in favor of direct Kopia directory snapshots (see docs/PROBLEM_1_PLAN.md). Direct snapshots provide file-level deduplication and are the recommended default.

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 โ†’


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 disaster-recovery  # Create DR bundle
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
sudo kopi-docka advanced repo maintenance # Run maintenance

# 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

# 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)

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:

  • 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

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


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-5.3.1.tar.gz (166.9 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-5.3.1-py3-none-any.whl (200.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for kopi_docka-5.3.1.tar.gz
Algorithm Hash digest
SHA256 6124c73bc4f3861713c59c91b2cbafc314b0176918eadd3d3646433a163acc0f
MD5 615330c5dcc6cb2ffe9735752b056596
BLAKE2b-256 a083656a0216e130bb3eb6324ca0d6cf98f4c976a98861fb8c123a84d0976dc6

See more details on using hashes here.

Provenance

The following attestation bundles were made for kopi_docka-5.3.1.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-5.3.1-py3-none-any.whl.

File metadata

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

File hashes

Hashes for kopi_docka-5.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 99f2a6a49214a664abbf7da139137cc958368730f64b9e2c415075d62ccd44a1
MD5 1194cb3a4813ee72fd327baa78f1cadd
BLAKE2b-256 ba693847b8bae30235cd022c53900d4843f54d66b32655840e6f7e0c56f245ec

See more details on using hashes here.

Provenance

The following attestation bundles were made for kopi_docka-5.3.1-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