|
|
@@ -84,7 +84,16 @@ def _read_archive_info(archive_name):
|
|
|
backup_dir = app.config["YUNOHOST_BACKUP_DIR"]
|
|
|
archive_path = os.path.join(backup_dir, archive_name + ".tar")
|
|
|
from jobs.utils import sudo_read_backup_info
|
|
|
- return sudo_read_backup_info(archive_path)
|
|
|
+ info = sudo_read_backup_info(archive_path)
|
|
|
+ if not info.get("type"):
|
|
|
+ # Archives YunoHost natives : déterminer le type depuis la table Run
|
|
|
+ run = Run.query.filter_by(archive_name=archive_name).first()
|
|
|
+ if run:
|
|
|
+ job = db.session.get(Job, run.job_id)
|
|
|
+ if job:
|
|
|
+ info["type"] = job.type
|
|
|
+ info["_from_run"] = True
|
|
|
+ return info
|
|
|
|
|
|
|
|
|
def _get_ynh_apps():
|
|
|
@@ -176,6 +185,30 @@ def archive_restore(archive_name):
|
|
|
elif archive_type in ("mysql", "postgresql"):
|
|
|
from jobs.db_dump import restore_db_dump
|
|
|
restore_db_dump(archive_name, backup_dir)
|
|
|
+ elif archive_type == "ynh_app":
|
|
|
+ result = subprocess.run(
|
|
|
+ ["sudo", "yunohost", "backup", "restore", archive_name,
|
|
|
+ "--apps", "--force"],
|
|
|
+ capture_output=True, text=True, timeout=3600,
|
|
|
+ )
|
|
|
+ if result.returncode != 0:
|
|
|
+ raise RuntimeError(
|
|
|
+ f"yunohost backup restore a échoué :\n"
|
|
|
+ f"{(result.stdout + result.stderr).strip()}"
|
|
|
+ )
|
|
|
+ app.logger.info(f"Restauration ynh_app {archive_name} OK")
|
|
|
+ elif archive_type == "ynh_system":
|
|
|
+ result = subprocess.run(
|
|
|
+ ["sudo", "yunohost", "backup", "restore", archive_name,
|
|
|
+ "--system", "--force"],
|
|
|
+ capture_output=True, text=True, timeout=3600,
|
|
|
+ )
|
|
|
+ if result.returncode != 0:
|
|
|
+ raise RuntimeError(
|
|
|
+ f"yunohost backup restore a échoué :\n"
|
|
|
+ f"{(result.stdout + result.stderr).strip()}"
|
|
|
+ )
|
|
|
+ app.logger.info(f"Restauration ynh_system {archive_name} OK")
|
|
|
else:
|
|
|
raise NotImplementedError(
|
|
|
f"Restauration non supportée pour le type '{archive_type}'."
|