mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[enh] Restore function
This commit is contained in:
parent
a4b5ec6f2d
commit
cde48996cf
4 changed files with 50 additions and 0 deletions
|
@ -562,6 +562,17 @@ backup:
|
|||
action_help: Create an encrypted backup tarball
|
||||
api: POST /backup
|
||||
|
||||
### backup_restore()
|
||||
restore:
|
||||
action_help: Restore from an encrypted backup tarball
|
||||
api: POST /restore
|
||||
configuration:
|
||||
authenticate: false
|
||||
lock: false
|
||||
arguments:
|
||||
path:
|
||||
help: Path of the restauration package
|
||||
|
||||
|
||||
#############################
|
||||
# Monitor #
|
||||
|
|
35
backup.py
35
backup.py
|
@ -52,3 +52,38 @@ def backup_backup():
|
|||
#TODO: Compress & encrypt
|
||||
|
||||
msignals.display(m18n.n('backup_complete'), 'success')
|
||||
|
||||
|
||||
def backup_restore(path):
|
||||
"""
|
||||
Restore from an encrypted backup tarball
|
||||
|
||||
Keyword argument:
|
||||
path -- Path to the restore directory
|
||||
|
||||
"""
|
||||
from yunohost.tools import tools_postinstall
|
||||
from yunohost.hook import hook_callback
|
||||
|
||||
path = os.path.abspath(path)
|
||||
|
||||
try:
|
||||
with open("%s/yunohost/current_host" % path, 'r') as f:
|
||||
domain = f.readline().rstrip()
|
||||
except IOError:
|
||||
raise MoulinetteError(errno.EINVAL, m18n.n('invalid_restore_package'))
|
||||
|
||||
#TODO Decrypt & extract tarball
|
||||
|
||||
try:
|
||||
with open('/etc/yunohost/installed') as f:
|
||||
raise MoulinetteError(errno.EINVAL, m18n.n('yunohost_already_installed'))
|
||||
except IOError:
|
||||
tools_postinstall(domain, 'yunohost', True)
|
||||
|
||||
# Run hook
|
||||
hook_callback('restore', [path])
|
||||
|
||||
msignals.display(m18n.n('restore_complete'), 'success')
|
||||
|
||||
|
||||
|
|
|
@ -129,6 +129,8 @@
|
|||
"system_upgraded" : "System successfully upgraded",
|
||||
|
||||
"backup_complete" : "Backup complete",
|
||||
"invalid_restore_package" : "Invalid restore package",
|
||||
"restore_complete" : "Restore complete",
|
||||
|
||||
"field_invalid" : "Invalid field '{:s}'",
|
||||
"mail_domain_unknown" : "Unknown mail address domain '{:s}'",
|
||||
|
|
|
@ -129,6 +129,8 @@
|
|||
"system_upgraded" : "Système mis à jour avec succès",
|
||||
|
||||
"backup_complete" : "Sauvegarde terminée",
|
||||
"invalid_restore_package" : "Dossier de restauration invalide",
|
||||
"restore_complete" : "Restauration terminée",
|
||||
|
||||
"field_invalid" : "Champ incorrect : {:s}",
|
||||
"mail_domain_unknown" : "Domaine '{:s}' de l'adresse mail inconnu",
|
||||
|
|
Loading…
Add table
Reference in a new issue