From caf2f4c41dd2b4263be8f4d399aa4035a28538e5 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Fri, 9 Apr 2021 19:11:26 +0200 Subject: [PATCH] Backup before upgrade before changing url --- scripts/change_url | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/scripts/change_url b/scripts/change_url index fb9f80f..8ca7483 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -8,7 +8,6 @@ source _common.sh source /usr/share/yunohost/helpers -ynh_abort_if_errors #================================================= # RETRIEVE ARGUMENTS @@ -31,6 +30,23 @@ ynh_script_progression --message="Loading installation settings..." --weight=1 final_path=$(ynh_app_setting_get --app=$app --key=final_path) port=$(ynh_app_setting_get --app=$app --key=port) +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --time --weight=1 + +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. + ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" + + # Restore it if the upgrade fails + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + #================================================= # CHECK WHICH PARTS SHOULD BE CHANGED #=================================================