From 689b390342afc32fd436d091252d15a3f71a49ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Lebleu?= Date: Fri, 22 Apr 2016 14:54:41 +0200 Subject: [PATCH] [fix] Restore current_host and use only one backup path for it --- data/hooks/backup/40-conf_ynh_currenthost | 7 ++----- data/hooks/restore/40-conf_ynh_currenthost | 2 ++ src/yunohost/backup.py | 6 +++--- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/data/hooks/backup/40-conf_ynh_currenthost b/data/hooks/backup/40-conf_ynh_currenthost index a91a50001..af054cad4 100644 --- a/data/hooks/backup/40-conf_ynh_currenthost +++ b/data/hooks/backup/40-conf_ynh_currenthost @@ -1,7 +1,4 @@ -backup_dir="$1/conf/ynh/" -backup_dir_legacy="$1/yunohost/" +backup_dir="$1/conf/ynh" sudo mkdir -p $backup_dir -sudo mkdir -p $backup_dir_legacy -sudo cp -a /etc/yunohost/current_host $backup_dir -sudo cp -a /etc/yunohost/current_host $backup_dir_legacy +sudo cp -a /etc/yunohost/current_host "${backup_dir}/current_host" diff --git a/data/hooks/restore/40-conf_ynh_currenthost b/data/hooks/restore/40-conf_ynh_currenthost index 8b1378917..a0bdf94d3 100644 --- a/data/hooks/restore/40-conf_ynh_currenthost +++ b/data/hooks/restore/40-conf_ynh_currenthost @@ -1 +1,3 @@ +backup_dir="$1/conf/ynh" +sudo cp -a "${backup_dir}/current_host" /etc/yunohost/current_host diff --git a/src/yunohost/backup.py b/src/yunohost/backup.py index 94b15ff42..430ecd570 100644 --- a/src/yunohost/backup.py +++ b/src/yunohost/backup.py @@ -375,11 +375,11 @@ def backup_restore(auth, name, hooks=[], ignore_hooks=False, else: # Retrieve the domain from the backup try: - with open("%s/yunohost/current_host" % tmp_dir, 'r') as f: + with open("%s/conf/ynh/current_host" % tmp_dir, 'r') as f: domain = f.readline().rstrip() except IOError: - logger.debug("unable to retrieve domain from " - "'%s/yunohost/current_host'", tmp_dir, exc_info=1) + logger.debug("unable to retrieve current_host from the backup", + exc_info=1) raise MoulinetteError(errno.EIO, m18n.n('backup_invalid_archive')) logger.debug("executing the post-install...")