|
|
@@ -29,7 +29,8 @@ def backup_custom_dir(job, instance, backup_dir):
|
|
|
archive_name = f"{instance}_{label}_{datetime.utcnow().strftime('%Y%m%d')}"
|
|
|
archive_path = os.path.join(backup_dir, archive_name + ".tar")
|
|
|
|
|
|
- if os.path.exists(archive_path):
|
|
|
+ from jobs.utils import sudo_exists
|
|
|
+ if sudo_exists(archive_path):
|
|
|
raise RuntimeError(
|
|
|
f"L'archive {archive_name}.tar existe déjà. "
|
|
|
"Supprimez-la ou attendez le prochain cycle."
|
|
|
@@ -119,7 +120,8 @@ def backup_custom_dir(job, instance, backup_dir):
|
|
|
def restore_custom_dir(archive_name, backup_dir):
|
|
|
"""Restauration complète d'un custom_dir : fichiers + user + service + permissions."""
|
|
|
archive_path = os.path.join(backup_dir, archive_name + ".tar")
|
|
|
- if not os.path.exists(archive_path):
|
|
|
+ from jobs.utils import sudo_exists
|
|
|
+ if not sudo_exists(archive_path):
|
|
|
raise FileNotFoundError(f"Archive introuvable : {archive_path}")
|
|
|
|
|
|
info = _read_backup_info(archive_path)
|