Automated Docker backup system for PostgreSQL databases and application configurations with Duplicati integration
BackupBot is a comprehensive backup solution that automatically discovers and backs up PostgreSQL containers, creates btrfs snapshots of your application data, and provides a web-based configuration interface. Built on top of LinuxServer.io's Duplicati image, it combines database backups with flexible cloud storage options.
- π Auto-Discovery: Automatically detects PostgreSQL containers by image patterns
- π Multi-Database Support: Backs up all databases within each PostgreSQL container using
pg_dumpall - πΈ Filesystem Snapshots: Creates read-only btrfs snapshots of application data
- π Automated Scheduling: Configurable backup times with retry logic
- π Web Interface: Simple configuration UI accessible on port 8080
- π Gotify Integration: Optional push notifications for backup failures
- ποΈ Duplicati Integration: Full access to Duplicati for cloud backup destinations
- π§Ή Retention Management: Automatic cleanup of old backups based on retention policy
- π³ Docker-Native: Designed to run in containerized environments
- Docker Engine 20.10+
- Docker Compose 2.0+
- Btrfs filesystem for snapshot functionality (optional but recommended)
- Running PostgreSQL containers you want to back up
-
Clone the repository:
git clone https://gitea.calahilstudios.com/owner/backupbot.git cd backupbot -
Start the container:
docker-compose up -d
-
Access the interfaces:
- BackupBot Config: http://localhost:8201
- Duplicati Web UI: http://localhost:8200
# Duplicati encryption key (required)
KEY=your_encryption_key_here
# Duplicati web password (required)
PASSWORD=your_secure_password
# User/Group IDs (optional)
PUID=1000
PGID=1000
# Timezone (optional)
TZ=America/Los_AngelesBackupBot settings are managed through the web interface at http://localhost:8201 or via the config file at /config/backupbot.conf:
TZ=America/Los_Angeles
BACKUP_DIR=/backups/postgres
LOG_FILE=/config/log/pgbackup.log
MAX_RETRIES=3
GOTIFY_URL=http://gotify.example.com
GOTIFY_TOKEN=your_gotify_token_here
BACKUP_HOUR=03
BACKUP_MINUTE=00
RETENTION_DAYS=7BackupBot automatically detects containers running these images:
postgres:17.0-alpinepostgres:17postgres:14.0-alpinepostgres(any version)ghcr.io/immich-app/postgres:*
Additional patterns can be added by modifying the KNOWN_IMAGES list in backup.sh.
volumes:
# Duplicati configuration
- /path/to/duplicati/config:/config
# Backup storage (where dumps are stored)
- /path/to/backups:/backups:rshared
# Docker socket (for container discovery)
- /var/run/docker.sock:/var/run/docker.sock:ro
# Source data for snapshots (optional)
- /path/to/appdata:/source:roTrigger a backup manually:
docker exec backupbot /usr/local/bin/backup.shMonitor backup operations:
docker logs -f backupbotBackups are organized by container name:
ls -lh /backups/postgres_dumps/Example structure:
/backups/
βββ postgres_dumps/
β βββ myapp_db/
β β βββ 2024-10-23_03-00-00.sql
β β βββ 2024-10-24_03-00-00.sql
β βββ another_db/
β βββ 2024-10-23_03-00-00.sql
βββ snapshots/
βββ hostname-2024-10-23/
βββ hostname-2024-10-24/
- Discovery Phase: BackupBot scans running Docker containers and identifies PostgreSQL instances
- Extraction: For each database, credentials are extracted from environment variables
- Backup:
pg_dumpallcreates a complete SQL dump of all databases - Snapshot: A read-only btrfs snapshot is created of
/source - Retention: Old backups exceeding the retention period are automatically deleted
- Notification: On failure after retries, Gotify notifications are sent (if configured)
- Privileged Mode: Required for btrfs snapshot functionality
- Docker Socket: Read-only access needed for container discovery
- Credentials: Database passwords are extracted from container environment variables
- Network: BackupBot runs in bridge mode by default
- Use strong encryption keys for Duplicati
- Restrict access to the web interfaces using a reverse proxy with authentication
- Regularly test backup restoration procedures
- Store encryption keys securely outside the container
-
BackupBot Config:
http://localhost:8201- Configure backup schedules
- Set retention policies
- Manage Gotify notifications
-
Duplicati:
http://localhost:8200- Configure cloud storage destinations
- Schedule remote backups
- Restore from backups
Set via BACKUPBOT_WEB_LOGGING environment variable:
DEBUG: Verbose logging with exception tracesINFO: Standard operational logs (default)WARN: Warnings and errors only
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request on Github
This project is licensed under the GNU Affero General Public License v3.0 - see the LICENSE file for details.
- Built on LinuxServer.io Duplicati
- PostgreSQL backup functionality inspired by community best practices
- Web interface uses vanilla JavaScript for minimal dependencies
- π Issues: Report bugs on Github
- π Documentation: This README and inline code comments
- π¬ Discussions: Open an issue for questions
- MySQL/MariaDB support
- MongoDB backup integration
- Advanced scheduling options (multiple backup windows)
- Backup verification and integrity checks
- Prometheus metrics export
- Email notifications
- Backup compression options
Made by Calahil Studios