From 0990b942f0dd3a00df96776bfd4ca77f0e728a28 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 8 Oct 2020 01:52:59 +0200 Subject: [PATCH] add data_backup --- scripts/backup | 8 ++++++++ scripts/upgrade | 10 +++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/scripts/backup b/scripts/backup index e3fec32..b77b5e3 100644 --- a/scripts/backup +++ b/scripts/backup @@ -29,6 +29,7 @@ app=$YNH_APP_INSTANCE_NAME final_path=$(ynh_app_setting_get --app=$app --key=final_path) domain=$(ynh_app_setting_get --app=$app --key=domain) +sync_home=$(ynh_app_setting_get --app=$app --key=sync_home) #================================================= # DECLARE DATA AND CONF FILES TO BACKUP @@ -55,6 +56,13 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup --src_path="/etc/systemd/system/$app.service" +#================================================= +# BACKUP THE DATA DIRECTORY +#================================================= +ynh_script_progression --message="Backing up data directory..." + +ynh_backup --src_path="$sync_home" --is_big + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 4213b5c..511612e 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -67,7 +67,7 @@ if [ -z $gui_port ]; then mkdir -p $final_path cp -R $OLD_SYNCHOME/.config $final_path/.config - ynh_replace_string "~" "$sync_home" "$final_path/.config/syncthing/config.xml" + ynh_replace_string --match_string="~" --replace_string="$sync_home" --target_file="$final_path/.config/syncthing/config.xml" systemctl stop syncthing@$OLD_SYNCUSER.service yunohost service remove syncthing@$OLD_SYNCUSER.service @@ -88,8 +88,16 @@ else #================================================= ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." + # Inform the backup/restore process that it should not save the data directory + # Use only for the previous backup script that doesn't set 'is_big' + ynh_app_setting_set --app=$app --key=backup_core_only --value=1 + # Backup the current version of the app ynh_backup_before_upgrade + + # Remove the option backup_core_only after the backup. + ynh_app_setting_delete --app=$app --key=backup_core_only + ynh_clean_setup () { ynh_clean_check_starting # restore it if the upgrade fails