26 Commits

Author SHA1 Message Date
2fa5bdfa7f readme work
Some checks failed
Build and Push Docker Image / build (push) Has been cancelled
2025-10-27 20:56:45 -07:00
846485b2e5 DEBUG 2025-10-27 20:37:53 -07:00
9267c98156 missed a sytle plate
Some checks failed
Build and Push Docker Image / build (push) Has been cancelled
2025-10-26 23:01:01 -07:00
9d691c5ff6 work on README.md
Some checks failed
Build and Push Docker Image / build (push) Has been cancelled
learning to use shields.io
2025-10-26 22:45:04 -07:00
0c7dffa047 it was there all along 2025-10-24 05:40:33 -07:00
aec2f05b00 removed the event line because it produced empty strings 2025-10-24 05:28:48 -07:00
3d856909c6 tweaked some variables 2025-10-24 05:15:53 -07:00
eb740236d7 debug 2025-10-24 05:12:38 -07:00
a2a23a8393 optimized and fixed the missing registry line for dockerhub 2025-10-24 05:07:28 -07:00
4a78aabfdb switching to github actions 2025-10-24 04:48:50 -07:00
5e33afb807 q
Some checks failed
Build and Push Docker Image / build (push) Failing after 10s
2025-10-23 17:41:46 -07:00
c1a7ffd9e8 try 4
All checks were successful
Build and Push Docker Image / build (push) Successful in 45s
2025-10-23 17:24:45 -07:00
b528097b00 step4
Some checks failed
Build and Push Docker Image / build (push) Failing after 8s
2025-10-23 17:16:43 -07:00
035811115e try 3
Some checks failed
Build and Push Docker Image / build (push) Failing after 8s
2025-10-23 17:08:05 -07:00
f1ddee1b6e step2
Some checks failed
Build and Push Docker Image / build (push) Failing after 8s
2025-10-23 16:02:40 -07:00
1b0631d4e8 test 2
Some checks failed
Build and Push Docker Image / build (push) Failing after 8s
2025-10-23 15:43:10 -07:00
6192b18a49 learning something new
Some checks failed
Build and Push Docker Image / build (push) Failing after 8s
2025-10-23 15:27:46 -07:00
fd222fc92a one two buckle my show
Some checks failed
Docker Image CI / build-and-push-image (push) Failing after 8s
2025-10-23 15:16:54 -07:00
bbc5245793 testing new workflow
Some checks failed
Docker Image CI / build-and-push-image (push) Has been cancelled
2025-10-23 14:57:42 -07:00
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
5 changed files with 95 additions and 143 deletions

View File

@@ -1,35 +0,0 @@
name: Build and Push Docker Image
on:
push:
branches:
- main
- develop
pull_request:
jobs:
build:
runs-on: prodesk
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Gitea Docker Registry
uses: docker/login-action@v3
with:
registry: gitea.calahilstudios.com
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Build and push image
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
tags: |
gitea.calahilstudios.com/${{ github.repository_owner }}/${{ github.event.repository.name }}:develop
gitea.calahilstudios.com/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ github.sha }}

77
.github/workflows/build.yml vendored Normal file
View File

@@ -0,0 +1,77 @@
name: Build and Push Docker Image
on:
push:
branches:
- main
tags:
- "v*"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# 🧠 Login to Docker Hub
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: docker.io
username: ${{ github.actor }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# 🧠 Login to GitHub Container Registry
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# 🧠 Login to Gitea
- name: Login to Gitea
uses: docker/login-action@v3
with:
registry: gitea.calahilstudios.com
username: ${{ github.actor }}
password: ${{ secrets.GITEA_TOKEN }}
- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository }}
gitea.calahilstudios.com/${{ github.repository }}
${{ github.repository }}
tags: |
# Always include short SHA
type=sha,format=short
# Include latest if on default branch (usually 'main' or 'develop')
type=raw,value=latest,enable={{is_default_branch}}
# If this is a semver tag (vX.X.X), add full + minor version tags
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Debug GitHub context
run: |
echo "Tags: ${{ steps.meta.outputs.tags }}"
echo "Labels: ${{ steps.meta.outputs.labels }}"
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

View File

@@ -1,9 +1,12 @@
# 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/owner/backupbot/status.svg)](https://gitea.calahilstudios.com/owner/backupbot)
[![Gitea](https://img.shields.io/badge/Gitea-calahilstudios.com-609926?logo=gitea&logoColor=white)](https://gitea.calahilstudios.com)
![Docker Image Version (tag)](https://img.shields.io/docker/v/calahil/backupbot/latest?arch=amd64&style=for-the-badge&logo=docker&logoColor=white&labelColor=blue&color=green)
![Docker Pulls](https://img.shields.io/docker/pulls/calahil/backupbot?style=for-the-badge&logo=docker&logoColor=white&labelColor=blue&color=green)
![Docker Stars](https://img.shields.io/docker/stars/calahil/backupbot?style=for-the-badge&logo=docker&logoColor=white&labelColor=blue&color=green)
![GitHub License](https://img.shields.io/github/license/calahil/backupbot?style=for-the-badge&logo=docker&logoColor=white&labelColor=blue&color=green)
![GitHub Release](https://img.shields.io/github/v/release/calahil/backupbot?display_name=release&style=for-the-badge&logo=github&labelColor=blue&color=green)
> **Automated Docker backup system for PostgreSQL databases and application configurations with Duplicati integration**
@@ -42,19 +45,12 @@ BackupBot is a comprehensive backup solution that automatically discovers and ba
cd backupbot
```
2. **Create environment file:**
```bash
cp .env.example .env
# Edit .env with your settings
nano .env
```
3. **Start the container:**
2. **Start the container:**
```bash
docker-compose up -d
```
4. **Access the interfaces:**
3. **Access the interfaces:**
- BackupBot Config: http://localhost:8201
- Duplicati Web UI: http://localhost:8200
@@ -64,8 +60,6 @@ BackupBot is a comprehensive backup solution that automatically discovers and ba
### Environment Variables
Create a `.env` file in the project root:
```env
# Duplicati encryption key (required)
KEY=your_encryption_key_here
@@ -116,16 +110,16 @@ Additional patterns can be added by modifying the `KNOWN_IMAGES` list in `backup
```yaml
volumes:
# Duplicati configuration
- /srv/appdata/duplicati/config:/config
- /path/to/duplicati/config:/config
# Backup storage (where dumps are stored)
- /srv/backups:/backups:rshared
- /path/to/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
- /path/to/appdata:/source:ro
```
---
@@ -153,12 +147,12 @@ docker logs -f backupbot
Backups are organized by container name:
```bash
ls -lh /srv/backups/postgres_dumps/
ls -lh /backups/postgres_dumps/
```
Example structure:
```
/srv/backups/
/backups/
├── postgres_dumps/
│ ├── myapp_db/
│ │ ├── 2024-10-23_03-00-00.sql
@@ -177,7 +171,7 @@ Example structure:
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`
4. **Snapshot**: A read-only btrfs snapshot is created of `/source`
5. **Retention**: Old backups exceeding the retention period are automatically deleted
6. **Notification**: On failure after retries, Gotify notifications are sent (if configured)
@@ -199,24 +193,6 @@ Example structure:
---
## 🛠️ 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
@@ -248,7 +224,7 @@ Contributions are welcome! Please feel free to submit a Pull Request.
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
5. Open a Pull Request on Github
---
@@ -256,12 +232,6 @@ Contributions are welcome! Please feel free to submit a Pull Request.
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
@@ -274,7 +244,7 @@ This project is licensed under the GNU Affero General Public License v3.0 - see
## 📞 Support
- 🐛 **Issues**: [Report bugs on Gitea](https://gitea.calahilstudios.com/owner/backupbot/issues)
- 🐛 **Issues**: [Report bugs on Github](https://github.com/calahil/backupbot/issues)
- 📚 **Documentation**: This README and inline code comments
- 💬 **Discussions**: Open an issue for questions
@@ -292,6 +262,4 @@ This project is licensed under the GNU Affero General Public License v3.0 - see
---
**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)
**Made by Calahil Studios**

View File

@@ -1,8 +0,0 @@
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

View File

@@ -1,50 +0,0 @@
#!/usr/bin/env python3
import cgi
import cgitb
import os
import json
cgitb.enable()
print("Content-Type: application/json\n")
ENV_FILE = "/config/web/backupbot.env"
def read_env():
env = {}
if os.path.exists(ENV_FILE):
with open(ENV_FILE) as f:
for line in f:
line = line.strip()
if not line or line.startswith("#") or "=" not in line:
continue
key, val = line.split("=", 1)
key = key.strip()
val = val.strip().split("#")[0].strip() # strip inline comments
env[key] = val
return env
def write_env(env):
with open(ENV_FILE, "w") as f:
for key, val in env.items():
f.write(f"{key}={val}\n")
form = cgi.FieldStorage()
action = form.getvalue("action")
if action == "get":
env = read_env()
print(json.dumps(env))
elif action == "set":
try:
raw = os.environ.get("CONTENT_LENGTH")
length = int(raw) if raw else 0
data = json.loads(os.read(0, length))
write_env(data)
print(json.dumps({"status": "ok", "message": "Configuration saved."}))
except Exception as e:
print(json.dumps({"status": "error", "message": str(e)}))
else:
print(json.dumps({"status": "error", "message": "Invalid action"}))