From 4c9e2c65b9a8dbddd4d4affefef7c0e1d0308190 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 11 Jan 2022 15:58:41 +0000 Subject: [PATCH] add db backup --- scripts/upgrade | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index e6a6717..44f4b07 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -62,6 +62,11 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app if $(ynh_compare_current_package_version --comparison gt --version "0.2.0~ynh1") then + # save redis db + pushd $final_path + redis-cli --rdb "/tmp/redis-$app.rdb" -p $redis_port + popd + ynh_systemd_action --service_name=redis-$app --action="stop" --log_path="/var/log/$app/redis-$app.log" fi #================================================= @@ -97,10 +102,16 @@ ynh_system_user_create --username=$app --home_dir="$final_path" if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_script_progression --message="Upgrading source files..." --weight=1 - + ynh_secure_remove --file="$final_path" # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path" + + # restore db backup + if $(ynh_compare_current_package_version --comparison gt --version "0.2.0~ynh1") + then + mv /tmp/redis-$app.rdb $final_path/redis-$app.rdb + fi fi if [ "$upgrade_type" == "UPGRADE_APP" ] @@ -139,7 +150,7 @@ ynh_add_systemd_config --service $redis_service --template "scrumblr_redis.servi chmod 750 "$final_path" chmod -R o-rwx "$final_path" -chown -R $app:redis "$final_path" +chown -R $app:$app "$final_path" #=================================================