mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Merge pull request #100 from zamentur/unstable
[enh] Add a yunohost backup delete action
This commit is contained in:
commit
1daae564ae
3 changed files with 43 additions and 2 deletions
|
@ -655,6 +655,16 @@ backup:
|
|||
help: Print sizes in human readable format
|
||||
action: store_true
|
||||
|
||||
### backup_delete()
|
||||
delete:
|
||||
action_help: Delete a backup archive
|
||||
api: DELETE /backup/archives/<name>
|
||||
arguments:
|
||||
name:
|
||||
help: Name of the archive to delete
|
||||
extra:
|
||||
pattern: *pattern_backup_archive_name
|
||||
|
||||
|
||||
#############################
|
||||
# Monitor #
|
||||
|
|
|
@ -383,7 +383,7 @@ def backup_info(name, with_details=False, human_readable=False):
|
|||
archive_file = '%s/%s.tar.gz' % (archives_path, name)
|
||||
if not os.path.isfile(archive_file):
|
||||
logger.error("no local backup archive found at '%s'", archive_file)
|
||||
raise MoulinetteError(errno.EIO, m18n.n('backup_archive_name_unknown'))
|
||||
raise MoulinetteError(errno.EIO, m18n.n('backup_archive_name_unknown',name))
|
||||
|
||||
info_file = "%s/%s.info.json" % (archives_path, name)
|
||||
try:
|
||||
|
@ -412,3 +412,32 @@ def backup_info(name, with_details=False, human_readable=False):
|
|||
for d in ['apps', 'hooks']:
|
||||
result[d] = info[d]
|
||||
return result
|
||||
|
||||
|
||||
def backup_delete(name):
|
||||
"""
|
||||
Delete a backup
|
||||
|
||||
Keyword arguments:
|
||||
name -- Name of the local backup archive
|
||||
|
||||
"""
|
||||
from yunohost.hook import hook_callback
|
||||
hook_callback('pre_backup_delete', args=[name])
|
||||
|
||||
archive_file = '%s/%s.tar.gz' % (archives_path, name)
|
||||
|
||||
info_file = "%s/%s.info.json" % (archives_path, name)
|
||||
for backup_file in [archive_file,info_file]:
|
||||
if not os.path.isfile(backup_file):
|
||||
logger.error("no local backup archive found at '%s'", backup_file)
|
||||
raise MoulinetteError(errno.EIO, m18n.n('backup_archive_name_unknown', backup_file))
|
||||
try:
|
||||
os.remove(backup_file)
|
||||
except:
|
||||
logger.exception("unable to delete '%s'", backup_file)
|
||||
raise MoulinetteError(errno.EIO, m18n.n('backup_delete_error',backup_file))
|
||||
|
||||
hook_callback('post_backup_delete', args=[name])
|
||||
|
||||
msignals.display(m18n.n('backup_deleted'), 'success')
|
||||
|
|
|
@ -147,7 +147,7 @@
|
|||
"backup_creating_archive" : "Creating the backup archive...",
|
||||
"backup_extracting_archive" : "Extracting the backup archive...",
|
||||
"backup_archive_open_failed" : "Unable to open the backup archive",
|
||||
"backup_archive_name_unknown" : "Unknown local backup archive name",
|
||||
"backup_archive_name_unknown" : "Unknown local backup archive named '{:s}'",
|
||||
"backup_archive_name_exists" : "Backup archive name already exists",
|
||||
"backup_complete" : "Backup complete",
|
||||
"backup_invalid_archive" : "Invalid backup archive",
|
||||
|
@ -157,6 +157,8 @@
|
|||
"restore_complete" : "Restore complete",
|
||||
"unbackup_app" : "App '{:s}' will not be saved",
|
||||
"unrestore_app" : "App '{:s}' will not be restored",
|
||||
"backup_delete_error" : "Unable to delete '{:s}'",
|
||||
"backup_deleted" : "Backup successfully deleted",
|
||||
|
||||
"field_invalid" : "Invalid field '{:s}'",
|
||||
"mail_domain_unknown" : "Unknown mail address domain '{:s}'",
|
||||
|
|
Loading…
Add table
Reference in a new issue