diff --git a/maloja/apis/native_v1.py b/maloja/apis/native_v1.py index d3c5c0e..a6260be 100644 --- a/maloja/apis/native_v1.py +++ b/maloja/apis/native_v1.py @@ -4,7 +4,7 @@ from ..__pkginfo__ import VERSION, VERSIONSTR from ..malojauri import uri_to_internal from .. import utilities -from bottle import response +from bottle import response, static_file # nimrodel API from nimrodel import EAPI as API @@ -335,5 +335,16 @@ def set_settings(**keys): @api.post("apikeys") @authenticated_api -def set_settings(**keys): +def set_apikeys(**keys): apikeystore.update(keys) + +@api.get("backup") +@authenticated_api +def get_backup(**keys): + from ..proccontrol.tasks.backup import backup + import tempfile + + tmpfolder = tempfile.gettempdir() + archivefile = backup(tmpfolder) + + return static_file(os.path.basename(archivefile),root=tmpfolder) diff --git a/maloja/proccontrol/tasks/backup.py b/maloja/proccontrol/tasks/backup.py index 95e81e9..7c7bbb5 100644 --- a/maloja/proccontrol/tasks/backup.py +++ b/maloja/proccontrol/tasks/backup.py @@ -14,14 +14,13 @@ user_files = { "scrobbles":["*.tsv"] }, "full":{ - "clients":["authenticated_machines.tsv"], + "clients":["apikeys.yml"], "images":["artists","tracks"], "settings":["settings.ini"] } } def backup(folder,level="full"): - print(folder) selected_files = user_files["minimal"] if level == "minimal" else {**user_files["minimal"], **user_files["full"]} real_files = {cat:[] for cat in selected_files} @@ -45,3 +44,4 @@ def backup(folder,level="full"): r = p.relative_to(data_dir[cat]()) archive.add(f,arcname=os.path.join(cat,r)) log("Backup created!") + return archivefile diff --git a/maloja/web/jinja/admin_overview.jinja b/maloja/web/jinja/admin_overview.jinja index 5568965..f2e6825 100644 --- a/maloja/web/jinja/admin_overview.jinja +++ b/maloja/web/jinja/admin_overview.jinja @@ -75,11 +75,27 @@ {% endif %} +