1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/syncthing_ynh.git synced 2024-09-03 20:26:23 +02:00

add data_backup

This commit is contained in:
yalh76 2020-10-08 01:52:59 +02:00
parent 36c6b16e1e
commit 0990b942f0
2 changed files with 17 additions and 1 deletions

View file

@ -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
#=================================================

View file

@ -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