14 Commits

Author SHA1 Message Date
cacd0086c1 badges are fun
All checks were successful
Build and Push Docker Image / build (push) Successful in 43s
2025-10-23 13:44:30 -07:00
d13c54c8df learning badges
Some checks failed
Build and Push Docker Image / build (push) Failing after 6s
2025-10-23 13:32:20 -07:00
874adb4e2e worked on README
Some checks failed
Build and Push Docker Image / build (push) Failing after 6s
2025-10-23 13:24:05 -07:00
f5d9f0e458 fixed the repo
Some checks failed
Build and Push Docker Image / build (push) Failing after 8s
2025-10-23 13:16:08 -07:00
3a838a92f9 and then it hit me
Some checks failed
Build and Push Docker Image / build (push) Failing after 7s
2025-10-23 12:59:50 -07:00
1d8c32eac3 im at a loss 2025-10-23 12:58:50 -07:00
dd9d6feb57 first commit of bot config 2025-10-23 12:57:22 -07:00
6f72c80511 added a README
Some checks failed
Build and Push Docker Image / build (push) Failing after 7s
2025-10-23 12:51:51 -07:00
81845f4b72 and then it hit me
Some checks failed
Build and Push Docker Image / build (push) Failing after 6s
2025-10-23 12:35:33 -07:00
e0f8fa47b9 im at a loss 2025-10-23 12:35:31 -07:00
c40db791f4 lets see if it reads the vars 2025-10-23 12:35:31 -07:00
a6a459dcd9 layering issues 2025-10-23 12:35:08 -07:00
416d2ab3e5 wrong directory being made 2025-10-23 12:30:51 -07:00
8bc1ae86e7 first commit of bot config 2025-10-23 12:28:07 -07:00
4 changed files with 313 additions and 4 deletions

View File

@@ -1,4 +1,3 @@
# Use LinuxServer.io Duplicati base
FROM linuxserver/duplicati:2.1.0
# Install Docker CLI, bash, python3, btrfs support and all the app directories
@@ -27,7 +26,6 @@ RUN apt-get update \
&& rm -rf /var/lib/apt/lists/* \
&& mkdir -p /usr/local/bin /config /etc/services.d/backupbot
# Copy the backup script
COPY backup.sh /usr/local/bin/backup.sh
RUN chmod +x /usr/local/bin/backup.sh
@@ -43,6 +41,7 @@ RUN chmod +x /etc/services.d/backupbot/run
# Copy web frontend
COPY web /app
RUN chmod +x /app/cgi-bin/backupbot.cgi
# Expose web frontend port
EXPOSE 8080

308
README.md
View File

@@ -1 +1,307 @@
Docker backup system for configs and databases
# BackupBot 🤖
[![License](https://img.shields.io/badge/License-AGPL%20v3-blue.svg)](https://www.gnu.org/licenses/agpl-3.0)
[![Docker](https://img.shields.io/badge/Docker-Enabled-2496ED?logo=docker&logoColor=white)](https://www.docker.com/)
[![Build Status](https://gitea.calahilstudios.com/api/badges/calahil/backupbot/status.svg)](https://gitea.calahilstudios.com/calahil/backupbot)
[![Gitea](https://img.shields.io/badge/Gitea-calahilstudios.com-609926?logo=gitea&logoColor=white)](https://gitea.calahilstudios.com)
[![Scarf.io pulls](https://scarf.sh/installs-badge/linuxserver-ci/linuxserver%2Fduplicati?color=94398d&label-color=555555&logo-color=ffffff&style=for-the-badge&package-type=docker)](https://scarf.sh)
[![Gitea Stars](https://img.shields.io/gitea/stars/calahil/backupbot?gitea_url=https%3A%2F%2Fgitea.calahilstudios.net&logo=gitea)](https://gitea.calahilstudios.com/calahil/backupbot)
[![GitHub Release](https://img.shields.io/github/release/linuxserver/docker-duplicati.svg?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&logo=github)](https://github.com/linuxserver/docker-duplicati/releases)
[![GitHub Package Repository](https://img.shields.io/static/v1.svg?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&label=linuxserver.io&message=GitHub%20Package&logo=github)](https://github.com/linuxserver/docker-duplicati/packages)
[![GitLab Container Registry](https://img.shields.io/static/v1.svg?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&label=linuxserver.io&message=GitLab%20Registry&logo=gitlab)](https://gitlab.com/linuxserver.io/docker-duplicati/container_registry)
[![Quay.io](https://img.shields.io/static/v1.svg?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&label=linuxserver.io&message=Quay.io)](https://quay.io/repository/linuxserver.io/duplicati)
[![Docker Pulls](https://img.shields.io/docker/pulls/linuxserver/duplicati.svg?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&label=pulls&logo=docker)](https://hub.docker.com/r/linuxserver/duplicati)
[![Docker Stars](https://img.shields.io/docker/stars/linuxserver/duplicati.svg?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&label=stars&logo=docker)](https://hub.docker.com/r/linuxserver/duplicati)
[![Jenkins Build](https://img.shields.io/jenkins/build?labelColor=555555&logoColor=ffffff&style=for-the-badge&jobUrl=https%3A%2F%2Fci.linuxserver.io%2Fjob%2FDocker-Pipeline-Builders%2Fjob%2Fdocker-duplicati%2Fjob%2Fmaster%2F&logo=jenkins)](https://ci.linuxserver.io/job/Docker-Pipeline-Builders/job/docker-duplicati/job/master/)
[![LSIO CI](https://img.shields.io/badge/dynamic/yaml?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&label=CI&query=CI&url=https%3A%2F%2Fci-tests.linuxserver.io%2Flinuxserver%2Fduplicati%2Flatest%2Fci-status.yml)](https://ci-tests.linuxserver.io/linuxserver/duplicati/latest/index.html)
> **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.
---
## ✨ Features
- 🔍 **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
---
## 🚀 Quick Start
### Prerequisites
- Docker Engine 20.10+
- Docker Compose 2.0+
- Btrfs filesystem for snapshot functionality (optional but recommended)
- Running PostgreSQL containers you want to back up
### Installation
1. **Clone the repository:**
```bash
git clone https://gitea.calahilstudios.com/owner/backupbot.git
cd backupbot
```
2. **Create environment file:**
```bash
cp .env.example .env
# Edit .env with your settings
nano .env
```
3. **Start the container:**
```bash
docker-compose up -d
```
4. **Access the interfaces:**
- BackupBot Config: http://localhost:8201
- Duplicati Web UI: http://localhost:8200
---
## 📋 Configuration
### Environment Variables
Create a `.env` file in the project root:
```env
# 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_Angeles
```
### BackupBot Configuration
BackupBot settings are managed through the web interface at `http://localhost:8201` or via the config file at `/config/backupbot.conf`:
```bash
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=7
```
### Supported PostgreSQL Images
BackupBot automatically detects containers running these images:
- `postgres:17.0-alpine`
- `postgres:17`
- `postgres:14.0-alpine`
- `postgres` (any version)
- `ghcr.io/immich-app/postgres:*`
Additional patterns can be added by modifying the `KNOWN_IMAGES` list in `backup.sh`.
---
## 🗂️ Volume Mappings
```yaml
volumes:
# Duplicati configuration
- /srv/appdata/duplicati/config:/config
# Backup storage (where dumps are stored)
- /srv/backups:/backups:rshared
# Docker socket (for container discovery)
- /var/run/docker.sock:/var/run/docker.sock:ro
# Source data for snapshots (optional)
- /srv/appdata:/source/appdata:ro
```
---
## 🔧 Usage
### Manual Backup
Trigger a backup manually:
```bash
docker exec backupbot /usr/local/bin/backup.sh
```
### View Logs
Monitor backup operations:
```bash
docker logs -f backupbot
```
### Check Backup Files
Backups are organized by container name:
```bash
ls -lh /srv/backups/postgres_dumps/
```
Example structure:
```
/srv/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/
```
---
## 🎯 How It Works
1. **Discovery Phase**: BackupBot scans running Docker containers and identifies PostgreSQL instances
2. **Extraction**: For each database, credentials are extracted from environment variables
3. **Backup**: `pg_dumpall` creates a complete SQL dump of all databases
4. **Snapshot**: A read-only btrfs snapshot is created of `/srv/appdata`
5. **Retention**: Old backups exceeding the retention period are automatically deleted
6. **Notification**: On failure after retries, Gotify notifications are sent (if configured)
---
## 🔐 Security Notes
- **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
### Best Practices
- 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
---
## 🛠️ Development
### Building from Source
```bash
docker build -t backupbot:latest .
```
### CI/CD Pipeline
BackupBot uses Gitea Actions for automated builds:
- **Trigger**: Push to `main` or `develop` branches
- **Registry**: `gitea.calahilstudios.com`
- **Tags**: `develop` and commit SHA
---
## 📊 Monitoring
### Web Interfaces
- **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
### Log Levels
Set via `BACKUPBOT_WEB_LOGGING` environment variable:
- `DEBUG`: Verbose logging with exception traces
- `INFO`: Standard operational logs (default)
- `WARN`: Warnings and errors only
---
## 🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request on Gitea
---
## 📝 License
This project is licensed under the GNU Affero General Public License v3.0 - see the [LICENSE](LICENSE) file for details.
**AGPL-3.0 Key Points:**
- ✅ Free to use, modify, and distribute
- ✅ Source code must be made available
- ✅ Network use is considered distribution
- ✅ Modifications must also be AGPL-3.0
---
## 🙏 Acknowledgments
- Built on [LinuxServer.io Duplicati](https://github.com/linuxserver/docker-duplicati)
- PostgreSQL backup functionality inspired by community best practices
- Web interface uses vanilla JavaScript for minimal dependencies
---
## 📞 Support
- 🐛 **Issues**: [Report bugs on Gitea](https://gitea.calahilstudios.com/owner/backupbot/issues)
- 📚 **Documentation**: This README and inline code comments
- 💬 **Discussions**: Open an issue for questions
---
## 🗺️ Roadmap
- [ ] 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 with ❤️ by Calahil Studios**
[![Gitea](https://img.shields.io/badge/View%20on-Gitea-609926?style=for-the-badge&logo=gitea&logoColor=white)](https://gitea.calahilstudios.com)

View File

@@ -17,7 +17,6 @@ services:
- /srv/backups:/backups:rshared
# Docker socket to list containers
- /var/run/docker.sock:/var/run/docker.sock:ro
ports:
- 8200:8200
- 8201:8080

View File

@@ -12,6 +12,11 @@ else
source /config/backupbot.conf
set +a
fi
# Initialize default web interface if missing
if [ ! -d /config/web ]; then
echo "[INFO] Populating /config/web from defaults..."
cp -r /defaults/web /config/
fi
# Start Python HTTP server for web config in background
cd /app