Borgmatic Backup System
Borgmatic for automated Borg backups with scheduling.
Overview
Borgmatic is a wrapper around BorgBackup that automates the process of creating, maintaining, and monitoring deduplicated backups. Created to simplify Borg's complex command-line interface, borgmatic provides declarative YAML configuration files and built-in scheduling capabilities, making enterprise-grade backup automation accessible to organizations of all sizes. The tool handles backup rotation, health checks, and repository maintenance automatically while preserving Borg's powerful deduplication and encryption features.
This Docker stack combines borgmatic with persistent storage volumes and configurable source directories to create a complete backup automation solution. The b3vis/borgmatic image includes cron scheduling and comprehensive logging, while Docker volumes ensure backup configurations and Borg caches survive container updates. The setup supports both local repositories and remote backup destinations including SSH, S3, and other cloud storage providers.
System administrators managing multiple servers, DevOps teams requiring automated backup workflows, and organizations needing compliance-ready backup retention policies will find this stack invaluable. The combination of Borg's space-efficient deduplication with borgmatic's automation reduces both storage costs and administrative overhead while maintaining enterprise-level reliability and security standards.
Key Features
- Automated backup scheduling with configurable retention policies and pruning rules
- BorgBackup deduplication engine reducing storage requirements by 80-95% for typical datasets
- Built-in health checks with configurable monitoring hooks for external alerting systems
- Support for multiple repository types including local, SSH, S3, and other cloud providers
- Automatic repository maintenance including compact operations and consistency checks
- Comprehensive logging and error reporting with customizable notification channels
- YAML-based configuration supporting multiple backup jobs and complex filtering rules
- Integration with monitoring systems through healthchecks.io, Prometheus, and webhook notifications
Common Use Cases
- 1Automated server backup workflows for production infrastructure with compliance requirements
- 2Development team data protection for source code repositories and build artifacts
- 3Database backup automation with point-in-time recovery capabilities
- 4Homelab and personal server backup management with minimal maintenance overhead
- 5Multi-tenant backup solutions for managed service providers
- 6Disaster recovery systems requiring offsite replication and encrypted storage
- 7Container volume backup for stateful applications in Docker and Kubernetes environments
Prerequisites
- Minimum 512MB RAM for small repositories, 2GB+ recommended for large datasets
- Sufficient disk space for Borg cache (typically 1-2% of total backup size)
- Network access to backup repositories if using remote storage destinations
- Understanding of Borg repository initialization and passphrase management
- Familiarity with YAML configuration syntax for borgmatic setup files
- SSH key configuration if backing up to remote repositories via SSH protocol
For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms
docker-compose.yml
docker-compose.yml
1services: 2 borgmatic: 3 image: b3vis/borgmatic:latest4 container_name: borgmatic5 restart: unless-stopped6 environment: 7 - TZ=${TZ:-UTC}8 - BORG_PASSPHRASE=${BORG_PASSPHRASE:-}9 volumes: 10 - ./borgmatic.d:/etc/borgmatic.d:ro11 - ${SOURCE_PATH:-./source}:/mnt/source:ro12 - ${REPO_PATH:-./repo}:/mnt/borg-repository13 - borgmatic_config:/root/.config/borg14 - borgmatic_cache:/root/.cache/borg15 networks: 16 - borgmatic-network1718volumes: 19 borgmatic_config: 20 borgmatic_cache: 2122networks: 23 borgmatic-network: 24 driver: bridge.env Template
.env
1# Borgmatic2TZ=UTC3BORG_PASSPHRASE=your-secure-passphrase4SOURCE_PATH=./source5REPO_PATH=./repoUsage Notes
- 1Create borgmatic.d/config.yaml
- 2Run borgmatic init first
- 3Cron scheduling built-in
- 4Supports remote repositories
Quick Start
terminal
1# 1. Create the compose file2cat > docker-compose.yml << 'EOF'3services:4 borgmatic:5 image: b3vis/borgmatic:latest6 container_name: borgmatic7 restart: unless-stopped8 environment:9 - TZ=${TZ:-UTC}10 - BORG_PASSPHRASE=${BORG_PASSPHRASE:-}11 volumes:12 - ./borgmatic.d:/etc/borgmatic.d:ro13 - ${SOURCE_PATH:-./source}:/mnt/source:ro14 - ${REPO_PATH:-./repo}:/mnt/borg-repository15 - borgmatic_config:/root/.config/borg16 - borgmatic_cache:/root/.cache/borg17 networks:18 - borgmatic-network1920volumes:21 borgmatic_config:22 borgmatic_cache:2324networks:25 borgmatic-network:26 driver: bridge27EOF2829# 2. Create the .env file30cat > .env << 'EOF'31# Borgmatic32TZ=UTC33BORG_PASSPHRASE=your-secure-passphrase34SOURCE_PATH=./source35REPO_PATH=./repo36EOF3738# 3. Start the services39docker compose up -d4041# 4. View logs42docker compose logs -fOne-Liner
Run this command to download and set up the recipe in one step:
terminal
1curl -fsSL https://docker.recipes/api/recipes/borgmatic-backup/run | bashTroubleshooting
- Repository does not exist error: Run 'borgmatic init' to initialize the repository before first backup
- Permission denied accessing source files: Ensure Docker container has read access to source directories and proper UID mapping
- Borg cache lock timeout errors: Remove stale lock files from borgmatic_cache volume or increase lock timeout values
- Out of disk space during backup: Configure appropriate pruning policies and monitor repository growth patterns
- Failed to create/acquire the lock: Stop any running borgmatic processes and remove lock files from the repository
- Backup verification failures: Check repository integrity with 'borg check' and verify source data hasn't been corrupted
Community Notes
Loading...
Loading notes...
Download Recipe Kit
Get all files in a ready-to-deploy package
Includes docker-compose.yml, .env template, README, and license
Ad Space
Shortcuts: C CopyF FavoriteD Download