mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[enh] Allow to ignore backup hooks execution at creation
This commit is contained in:
parent
1daae564ae
commit
999a61d2b2
3 changed files with 16 additions and 6 deletions
|
@ -594,6 +594,9 @@ backup:
|
|||
--hooks:
|
||||
help: List of backup hooks names to execute
|
||||
nargs: "*"
|
||||
--ignore-hooks:
|
||||
help: Do not execute backup hooks
|
||||
action: store_true
|
||||
--apps:
|
||||
help: List of application names to backup
|
||||
nargs: "*"
|
||||
|
|
|
@ -43,7 +43,8 @@ logger = getActionLogger('yunohost.backup')
|
|||
|
||||
|
||||
def backup_create(name=None, description=None, output_directory=None,
|
||||
no_compress=False, hooks=[], apps=[], ignore_apps=False):
|
||||
no_compress=False, ignore_hooks=False, hooks=[],
|
||||
ignore_apps=False, apps=[]):
|
||||
"""
|
||||
Create a backup local archive
|
||||
|
||||
|
@ -53,6 +54,7 @@ def backup_create(name=None, description=None, output_directory=None,
|
|||
output_directory -- Output directory for the backup
|
||||
no_compress -- Do not create an archive file
|
||||
hooks -- List of backup hooks names to execute
|
||||
ignore_hooks -- Do not execute backup hooks
|
||||
apps -- List of application names to backup
|
||||
ignore_apps -- Do not backup apps
|
||||
|
||||
|
@ -62,6 +64,11 @@ def backup_create(name=None, description=None, output_directory=None,
|
|||
|
||||
tmp_dir = None
|
||||
|
||||
# Validate what to backup
|
||||
if ignore_hooks and ignore_apps:
|
||||
raise MoulinetteError(errno.EINVAL,
|
||||
m18n.n('backup_action_required'))
|
||||
|
||||
# Validate and define backup name
|
||||
timestamp = int(time.time())
|
||||
if not name:
|
||||
|
@ -126,11 +133,10 @@ def backup_create(name=None, description=None, output_directory=None,
|
|||
}
|
||||
|
||||
# Run system hooks
|
||||
msignals.display(m18n.n('backup_running_hooks'))
|
||||
hooks_ret = hook_callback('backup', hooks, args=[tmp_dir])
|
||||
|
||||
# Add hooks results to the info
|
||||
info['hooks'] = hooks_ret['succeed']
|
||||
if not ignore_hooks:
|
||||
msignals.display(m18n.n('backup_running_hooks'))
|
||||
hooks_ret = hook_callback('backup', hooks, args=[tmp_dir])
|
||||
info['hooks'] = hooks_ret['succeed']
|
||||
|
||||
# Backup apps
|
||||
if not ignore_apps:
|
||||
|
|
|
@ -139,6 +139,7 @@
|
|||
"packages_upgrade_failed" : "Unable to upgrade all packages",
|
||||
"system_upgraded" : "System successfully upgraded",
|
||||
|
||||
"backup_action_required" : "You must specify something to backup",
|
||||
"backup_output_directory_required" : "You must provide an output directory for the backup",
|
||||
"backup_output_directory_forbidden" : "Forbidden output directory",
|
||||
"backup_output_directory_not_empty" : "Output directory is not empty",
|
||||
|
|
Loading…
Add table
Reference in a new issue