feat: backup system for portal DB and WLED configs

Portal DB:
- Download current DB button
- Manual backup creation
- Auto-backup daily at 02:00 (keeps last 14)
- Download/delete individual backups

WLED Config:
- Backup all devices at once
- Backup individual device
- Download config as JSON
- Restore config to any device
- Delete old backups

New sidebar menu item 'Backup' with dedicated page.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-24 12:55:06 +02:00
co-authored by Claude Opus 4.6
parent 4b6c20e638
commit 06253e3fef
5 changed files with 414 additions and 3 deletions
+24
View File
@@ -45,3 +45,27 @@ def get_wled_info(hostname):
return {"online": False}
except requests.exceptions.RequestException:
return {"online": False}
def get_wled_config(hostname):
"""Download full WLED config as JSON."""
try:
r = requests.get(f"http://{hostname}/cfg.json", timeout=TIMEOUT)
if r.status_code == 200:
return r.json()
return None
except requests.exceptions.RequestException:
return None
def restore_wled_config(hostname, config_json):
"""Push config JSON to WLED device."""
try:
r = requests.post(
f"http://{hostname}/json/cfg",
json=config_json,
timeout=TIMEOUT,
)
return r.status_code == 200, f"{r.status_code} {r.reason}"
except requests.exceptions.RequestException as e:
return False, str(e)