diff --git a/scripts/_common.sh b/scripts/_common.sh index 57498dc..b96aed6 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -74,7 +74,10 @@ ynh_redis_restore_db() { # Dump a database # ynh_redis_dump_db() { - redis-cli SET mykey $db + # Declare an array to define the options of this helper. + local db=$1 + + redis-cli SET mykey "$db" redis-cli --raw dump mykey | head -c-1 > $dump_location } diff --git a/scripts/backup b/scripts/backup index b66f2b1..0cf894b 100644 --- a/scripts/backup +++ b/scripts/backup @@ -56,6 +56,13 @@ ynh_backup --src_path="/etc/logrotate.d/$app" ynh_backup --src_path="/etc/systemd/system/$app.service" +#================================================= +# BACKUP THE REDIS DATABASE +#================================================= +ynh_print_info --message="Backing up the Redis database..." + +ynh_redis_dump_db + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index b157204..20320fd 100644 --- a/scripts/restore +++ b/scripts/restore @@ -29,9 +29,6 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_user=$db_name -db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) #================================================= # CHECK IF ETHERPAD CAN BE RESTORED @@ -75,20 +72,15 @@ chmod 400 $final_path/credentials.json #================================================= ynh_script_progression --message="Reinstalling dependencies..." --weight=7 -# Define and install dependencies -ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies - # Install Nodejs ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version #================================================= -# RESTORE THE POSTQRESQL DATABASE +# RESTORE THE REDIS DATABASE #================================================= -ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=2 +ynh_script_progression --message="Restoring the Redis database..." --weight=1 -ynh_psql_test_if_first_run -ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd -ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name +ynh_redis_restore_db #================================================= # RESTORE SYSTEMD