mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[fix] Backup restore
This commit is contained in:
parent
3563e8dc10
commit
be8216c0b4
3 changed files with 26 additions and 14 deletions
|
@ -1092,10 +1092,11 @@ backup:
|
||||||
arguments:
|
arguments:
|
||||||
repository:
|
repository:
|
||||||
help: Repository of the backup archive
|
help: Repository of the backup archive
|
||||||
name:
|
archive_name:
|
||||||
help: Name of the archive to delete
|
help: Name of the archive to delete
|
||||||
extra:
|
extra:
|
||||||
pattern: *pattern_backup_archive_name
|
pattern: *pattern_backup_archive_name
|
||||||
|
nargs: "*"
|
||||||
|
|
||||||
subcategories:
|
subcategories:
|
||||||
repository:
|
repository:
|
||||||
|
|
|
@ -1107,7 +1107,24 @@ class RestoreManager:
|
||||||
|
|
||||||
filesystem.mkdir(self.work_dir, parents=True)
|
filesystem.mkdir(self.work_dir, parents=True)
|
||||||
|
|
||||||
self.archive.extract()
|
# Select paths to extract
|
||||||
|
paths = ["backup.csv", "info.json", "hooks"]
|
||||||
|
paths += [f"apps/{app}" for app in self.targets.list("apps", exclude=["Skipped"])]
|
||||||
|
for system in self.targets.list("system", exclude=["Skipped"]):
|
||||||
|
if system.startswith("data"):
|
||||||
|
paths.append(f"data/{system}")
|
||||||
|
elif system.startswith("conf_ynh"):
|
||||||
|
if "conf/ynh" not in paths:
|
||||||
|
paths.append("conf/ynh")
|
||||||
|
else:
|
||||||
|
paths.append(system.replace("_", "/", 1))
|
||||||
|
|
||||||
|
if not self.targets.list("system", exclude=["Skipped"]):
|
||||||
|
paths.remove("hooks")
|
||||||
|
|
||||||
|
logger.debug(f"List of paths to extract: {paths}")
|
||||||
|
|
||||||
|
self.archive.extract(paths=paths, destination=self.work_dir)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Space computation / checks #
|
# Space computation / checks #
|
||||||
|
@ -1717,7 +1734,7 @@ def backup_create(
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
repo_results = backup_manager.backup()
|
repo_results = backup_manager.backup()
|
||||||
repo_states = [repo_result == "Success" for repository, repo_result in repo_results.items()]
|
repo_states = [repo_result == "Sent" for repository, repo_result in repo_results.items()]
|
||||||
|
|
||||||
if all(repo_states) and all(parts_states):
|
if all(repo_states) and all(parts_states):
|
||||||
logger.success(m18n.n("backup_created"))
|
logger.success(m18n.n("backup_created"))
|
||||||
|
@ -1886,7 +1903,7 @@ def backup_info(repository, name, with_details=False, human_readable=False):
|
||||||
return archive.info(with_details=with_details, human_readable=human_readable)
|
return archive.info(with_details=with_details, human_readable=human_readable)
|
||||||
|
|
||||||
|
|
||||||
def backup_delete(repository, name):
|
def backup_delete(repository, archive_name):
|
||||||
"""
|
"""
|
||||||
Delete a backup
|
Delete a backup
|
||||||
|
|
||||||
|
@ -1894,15 +1911,9 @@ def backup_delete(repository, name):
|
||||||
name -- Name of the local backup archive
|
name -- Name of the local backup archive
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
for name in archive_name:
|
||||||
repo = BackupRepository(repository)
|
repo = BackupRepository(repository)
|
||||||
archive = BackupArchive(repo, name)
|
BackupArchive(repo, name).delete()
|
||||||
|
|
||||||
# FIXME Those are really usefull ?
|
|
||||||
hook_callback("pre_backup_delete", args=[name])
|
|
||||||
|
|
||||||
archive.delete()
|
|
||||||
|
|
||||||
hook_callback("post_backup_delete", args=[name])
|
|
||||||
|
|
||||||
logger.success(m18n.n("backup_deleted"))
|
logger.success(m18n.n("backup_deleted"))
|
||||||
|
|
||||||
|
|
|
@ -259,7 +259,7 @@ class BorgBackupArchive(BackupArchive):
|
||||||
response.content_type = "application/x-tar"
|
response.content_type = "application/x-tar"
|
||||||
return HTTPResponse(reader, 200)
|
return HTTPResponse(reader, 200)
|
||||||
|
|
||||||
def extract(self, paths=None, destination=None, exclude_paths=[]):
|
def extract(self, paths=[], destination=None, exclude_paths=[]):
|
||||||
paths, destination, exclude_paths = super().extract(paths, destination, exclude_paths)
|
paths, destination, exclude_paths = super().extract(paths, destination, exclude_paths)
|
||||||
cmd = ['borg', 'extract', self.archive_path] + paths
|
cmd = ['borg', 'extract', self.archive_path] + paths
|
||||||
for path in exclude_paths:
|
for path in exclude_paths:
|
||||||
|
|
Loading…
Add table
Reference in a new issue