first commit of bot config
This commit is contained in:
@@ -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
|
||||||
|
|||||||
23
backupbot.env
Normal file
23
backupbot.env
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
# === BackupBot Environment Configuration ===
|
||||||
|
# Used by backup_scheduler.sh and web frontend
|
||||||
|
# Do not store sensitive credentials in world-readable locations unless necessary
|
||||||
|
|
||||||
|
# Timezone for scheduling backups (affects 3 AM backup)
|
||||||
|
TZ=America/Los_Angeles
|
||||||
|
|
||||||
|
# Directory to store backup SQL files
|
||||||
|
BACKUP_DIR=/backups/postgres
|
||||||
|
|
||||||
|
# Log file path
|
||||||
|
LOG_FILE=/config/log/pgbackup.log
|
||||||
|
|
||||||
|
# Number of retry attempts on failure
|
||||||
|
MAX_RETRIES=3
|
||||||
|
|
||||||
|
# Gotify notification configuration (optional)
|
||||||
|
GOTIFY_URL=http://gotify.example.com
|
||||||
|
GOTIFY_TOKEN=your_gotify_token_here
|
||||||
|
|
||||||
|
# Backup time (24-hour format) – defaults to 03:00 local time
|
||||||
|
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
|
||||||
|
|||||||
47
web/backupbot.cgi
Normal file
47
web/backupbot.cgi
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
#!/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 line and not line.startswith("#") and "=" in line:
|
||||||
|
key, val = line.split("=", 1)
|
||||||
|
env[key.strip()] = val.strip()
|
||||||
|
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