Compare commits
6 Commits
0b7f731764
...
81845f4b72
| Author | SHA1 | Date | |
|---|---|---|---|
| 81845f4b72 | |||
| e0f8fa47b9 | |||
| c40db791f4 | |||
| a6a459dcd9 | |||
| 416d2ab3e5 | |||
| 8bc1ae86e7 |
@@ -1,4 +1,3 @@
|
|||||||
# Use LinuxServer.io Duplicati base
|
|
||||||
FROM linuxserver/duplicati:2.1.0
|
FROM linuxserver/duplicati:2.1.0
|
||||||
|
|
||||||
# Install Docker CLI, bash, python3, btrfs support and all the app directories
|
# 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/* \
|
&& rm -rf /var/lib/apt/lists/* \
|
||||||
&& mkdir -p /usr/local/bin /config /etc/services.d/backupbot
|
&& mkdir -p /usr/local/bin /config /etc/services.d/backupbot
|
||||||
|
|
||||||
# Copy the backup script
|
|
||||||
COPY backup.sh /usr/local/bin/backup.sh
|
COPY backup.sh /usr/local/bin/backup.sh
|
||||||
RUN chmod +x /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 frontend
|
||||||
COPY web /app
|
COPY web /app
|
||||||
RUN chmod +x /app/cgi-bin/backupbot.cgi
|
RUN chmod +x /app/cgi-bin/backupbot.cgi
|
||||||
|
|
||||||
# Expose web frontend port
|
# Expose web frontend port
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
|
|
||||||
|
|||||||
8
backupbot.env
Normal file
8
backupbot.env
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
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
|
||||||
@@ -17,7 +17,6 @@ services:
|
|||||||
- /srv/backups:/backups:rshared
|
- /srv/backups:/backups:rshared
|
||||||
# Docker socket to list containers
|
# Docker socket to list containers
|
||||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||||
|
|
||||||
ports:
|
ports:
|
||||||
- 8200:8200
|
- 8200:8200
|
||||||
- 8201:8080
|
- 8201:8080
|
||||||
|
|||||||
@@ -12,6 +12,11 @@ else
|
|||||||
source /config/backupbot.conf
|
source /config/backupbot.conf
|
||||||
set +a
|
set +a
|
||||||
fi
|
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
|
# Start Python HTTP server for web config in background
|
||||||
cd /app
|
cd /app
|
||||||
|
|||||||
50
web/backupbot.cgi
Normal file
50
web/backupbot.cgi
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
#!/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"}))
|
||||||
Reference in New Issue
Block a user