mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Added backup from web interface
This commit is contained in:
parent
03e741c0ae
commit
af569ae983
@ -4,7 +4,7 @@ from ..__pkginfo__ import VERSION, VERSIONSTR
|
|||||||
from ..malojauri import uri_to_internal
|
from ..malojauri import uri_to_internal
|
||||||
from .. import utilities
|
from .. import utilities
|
||||||
|
|
||||||
from bottle import response
|
from bottle import response, static_file
|
||||||
|
|
||||||
# nimrodel API
|
# nimrodel API
|
||||||
from nimrodel import EAPI as API
|
from nimrodel import EAPI as API
|
||||||
@ -335,5 +335,16 @@ def set_settings(**keys):
|
|||||||
|
|
||||||
@api.post("apikeys")
|
@api.post("apikeys")
|
||||||
@authenticated_api
|
@authenticated_api
|
||||||
def set_settings(**keys):
|
def set_apikeys(**keys):
|
||||||
apikeystore.update(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)
|
||||||
|
@ -14,14 +14,13 @@ user_files = {
|
|||||||
"scrobbles":["*.tsv"]
|
"scrobbles":["*.tsv"]
|
||||||
},
|
},
|
||||||
"full":{
|
"full":{
|
||||||
"clients":["authenticated_machines.tsv"],
|
"clients":["apikeys.yml"],
|
||||||
"images":["artists","tracks"],
|
"images":["artists","tracks"],
|
||||||
"settings":["settings.ini"]
|
"settings":["settings.ini"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def backup(folder,level="full"):
|
def backup(folder,level="full"):
|
||||||
print(folder)
|
|
||||||
|
|
||||||
selected_files = user_files["minimal"] if level == "minimal" else {**user_files["minimal"], **user_files["full"]}
|
selected_files = user_files["minimal"] if level == "minimal" else {**user_files["minimal"], **user_files["full"]}
|
||||||
real_files = {cat:[] for cat in selected_files}
|
real_files = {cat:[] for cat in selected_files}
|
||||||
@ -45,3 +44,4 @@ def backup(folder,level="full"):
|
|||||||
r = p.relative_to(data_dir[cat]())
|
r = p.relative_to(data_dir[cat]())
|
||||||
archive.add(f,arcname=os.path.join(cat,r))
|
archive.add(f,arcname=os.path.join(cat,r))
|
||||||
log("Backup created!")
|
log("Backup created!")
|
||||||
|
return archivefile
|
||||||
|
@ -75,11 +75,27 @@
|
|||||||
<button type="button" id="adminmodebutton" onclick="activate()">Activate</button>
|
<button type="button" id="adminmodebutton" onclick="activate()">Activate</button>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
<h2>Download Data</h2>
|
||||||
|
|
||||||
|
Download your data to store local backups.<br/><br/>
|
||||||
|
|
||||||
|
<a href="/apis/mlj_1/backup" download="maloja_backup.tar.gz">
|
||||||
|
<button type="button">Download Backup</button>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h2>Links</h2>
|
<h2>Links</h2>
|
||||||
|
|
||||||
<a class="textlink" target="_blank" rel="noopener noreferrer" href="https://github.com/krateng/maloja/issues/new">Report Issue</a><br/>
|
<a class="textlink" target="_blank" rel="noopener noreferrer" href="https://github.com/krateng/maloja/issues/new">Report Issue</a><br/>
|
||||||
<a class="textlink" target="_blank" rel="noopener noreferrer" href="https://github.com/krateng/maloja/blob/master/README.md">Readme</a><br/>
|
<a class="textlink" target="_blank" rel="noopener noreferrer" href="https://github.com/krateng/maloja/blob/master/README.md">Readme</a><br/>
|
||||||
<a class="textlink" target="_blank" rel="noopener noreferrer" href="https://pypi.org/project/malojaserver/">PyPi</a><br/>
|
<a class="textlink" target="_blank" rel="noopener noreferrer" href="https://pypi.org/project/malojaserver/">PyPi</a><br/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{% if false %}
|
{% if false %}
|
||||||
<h2>Change Password</h2>
|
<h2>Change Password</h2>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user