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 admin 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 admin 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 admin 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

3. Tailscale Integration

Automatic peer discovery for P2P backups over WireGuard mesh network:

sudo kopi-docka admin 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 admin config show      # Show config
sudo kopi-docka admin config new       # Create new config
sudo kopi-docka admin config edit      # Edit config

# Repository
sudo kopi-docka admin repo init        # Initialize repository
sudo kopi-docka admin repo status      # Repository info
sudo kopi-docka admin repo maintenance # Run maintenance

# Snapshots & Units
sudo kopi-docka admin snapshot list          # List backup units
sudo kopi-docka admin snapshot list --snapshots  # List all snapshots
sudo kopi-docka admin snapshot estimate-size # Estimate backup size

# System & Service
sudo kopi-docka admin system install-deps    # Install dependencies
sudo kopi-docka admin service write-units    # Generate systemd units
sudo kopi-docka admin 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.10+ (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.2.0.tar.gz (158.6 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.2.0-py3-none-any.whl (193.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: kopi_docka-5.2.0.tar.gz
  • Upload date:
  • Size: 158.6 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.2.0.tar.gz
Algorithm Hash digest
SHA256 88cfa9009fa59edbe84e1330a1f7081c4505578336d4495ac7f3b0502631652d
MD5 736b369aec8b8198d64a164bd98d1132
BLAKE2b-256 1e6c3882b8865d81a0a54927e98a9ee8dd61ca15d478b92cc21d39d2c04a387f

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: kopi_docka-5.2.0-py3-none-any.whl
  • Upload date:
  • Size: 193.1 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bd687f7dc493988122013164fc46112dbba95188e76eb0d3cbc4c6bf161b0b81
MD5 227cfa297df380bff4715ace4b3bd63f
BLAKE2b-256 7285361193b849257439625768a83d853f477051882bdf263dd9bce7f412a05e

See more details on using hashes here.

Provenance

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