2018-04-29 13:00:03 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
2021-05-15 19:19:38 +02:00
|
|
|
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
2019-06-14 18:57:58 +02:00
|
|
|
source ../settings/scripts/_common.sh
|
2020-03-29 05:02:23 +02:00
|
|
|
source /usr/share/yunohost/helpers
|
2018-04-29 13:00:03 +02:00
|
|
|
|
2020-06-03 01:58:54 +02:00
|
|
|
#=================================================
|
|
|
|
# RESTORE THE APP MAIN DIR
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Restoring the app main directory..." --weight=1
|
|
|
|
|
2024-03-16 13:58:59 +01:00
|
|
|
ynh_restore_file --origin_path="$install_dir"
|
2019-06-19 02:18:00 +02:00
|
|
|
|
2024-03-16 13:58:59 +01:00
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R $app:www-data "$install_dir"
|
2018-04-29 13:00:03 +02:00
|
|
|
|
2024-03-16 13:58:59 +01:00
|
|
|
chmod 2775 "$install_dir/app/sites/default/files"
|
2018-04-29 13:00:03 +02:00
|
|
|
|
|
|
|
#=================================================
|
2021-05-15 19:19:38 +02:00
|
|
|
# RESTORE THE DATA DIRECTORY
|
2018-04-29 13:00:03 +02:00
|
|
|
#=================================================
|
2021-05-18 02:21:01 +02:00
|
|
|
ynh_script_progression --message="Restoring the data directory..."
|
2018-04-29 13:00:03 +02:00
|
|
|
|
2024-03-16 13:58:59 +01:00
|
|
|
ynh_restore_file --origin_path="$data_dir" --not_mandatory
|
2019-08-05 03:11:07 +02:00
|
|
|
|
2024-03-16 13:58:59 +01:00
|
|
|
chmod -R o-rwx "$data_dir"
|
|
|
|
chown -R "$app:www-data" "$data_dir"
|
2018-04-29 13:00:03 +02:00
|
|
|
|
2022-07-29 01:12:30 +02:00
|
|
|
#=================================================
|
2024-03-16 13:58:59 +01:00
|
|
|
# RESTORE THE POSTGRESQL DATABASE
|
2022-07-29 01:12:30 +02:00
|
|
|
#=================================================
|
2024-03-16 13:58:59 +01:00
|
|
|
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1
|
2022-07-29 01:12:30 +02:00
|
|
|
|
2024-03-16 13:58:59 +01:00
|
|
|
ynh_psql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < ./db.sql
|
2022-07-29 01:12:30 +02:00
|
|
|
|
2018-04-29 13:00:03 +02:00
|
|
|
#=================================================
|
2024-03-16 13:58:59 +01:00
|
|
|
# RESTORE SYSTEM CONFIGURATIONS
|
2018-04-29 13:00:03 +02:00
|
|
|
#=================================================
|
2024-03-16 13:58:59 +01:00
|
|
|
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
|
2018-04-29 13:00:03 +02:00
|
|
|
|
2020-06-04 22:59:34 +02:00
|
|
|
# Restore the file first, so it can have a backup if different
|
2020-06-03 01:58:54 +02:00
|
|
|
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
|
2018-04-29 13:00:03 +02:00
|
|
|
|
2020-06-04 22:59:34 +02:00
|
|
|
# Recreate a dedicated php-fpm config
|
2024-03-16 13:58:59 +01:00
|
|
|
# ynh_add_fpm_config --usage=low --footprint=low
|
2019-06-19 02:18:00 +02:00
|
|
|
|
2022-07-29 01:12:30 +02:00
|
|
|
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
2019-06-19 02:18:00 +02:00
|
|
|
|
2022-07-29 01:12:30 +02:00
|
|
|
ynh_restore_file --origin_path="/etc/cron.d/$app"
|
2018-04-29 13:00:03 +02:00
|
|
|
|
|
|
|
#=================================================
|
2019-06-14 18:57:58 +02:00
|
|
|
# RELOAD NGINX AND PHP-FPM
|
2018-04-29 13:00:03 +02:00
|
|
|
#=================================================
|
2020-10-01 22:37:20 +02:00
|
|
|
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=1
|
2018-04-29 13:00:03 +02:00
|
|
|
|
2024-03-16 13:58:59 +01:00
|
|
|
ynh_systemd_action --service_name="php$phpversion-fpm" --action=reload
|
2019-06-14 18:57:58 +02:00
|
|
|
ynh_systemd_action --service_name=nginx --action=reload
|
2018-04-29 13:00:03 +02:00
|
|
|
|
|
|
|
#=================================================
|
2019-06-14 18:57:58 +02:00
|
|
|
# END OF SCRIPT
|
2018-04-29 13:00:03 +02:00
|
|
|
#=================================================
|
|
|
|
|
2020-03-29 05:02:23 +02:00
|
|
|
ynh_script_progression --message="Restoration completed for $app" --last
|