1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/wordpress_ynh.git synced 2024-09-03 20:36:10 +02:00
wordpress_ynh/scripts/restore

78 lines
3 KiB
Bash

#!/bin/bash
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# ACTIVATE MAINTENANCE MODE
#=================================================
ynh_maintenance_mode_ON
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression "Restoring the app main directory..."
ynh_restore "$install_dir"
# Set file and directories ownership
mkdir -p $install_dir/wp-content/uploads
mkdir -p $install_dir/wp-content/temp
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:www-data "$install_dir"
find "$install_dir" -type d -exec chmod 750 {} \;
find "$install_dir" -type f -exec chmod 640 {} \;
find "$install_dir/wp-content/uploads" -type d -exec chmod 770 {} \;
find "$install_dir/wp-content/temp" -type d -exec chmod 770 {} \;
setfacl -Rm d:g:www-data:rwX "$install_dir/wp-content/uploads"
setfacl -Rm d:g:www-data:rwX "$install_dir/wp-content/temp"
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 400 "$install_dir/wp-config.php"
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown $app:$app "$install_dir/wp-config.php"
#=================================================
# RESTORE THE MYSQL DATABASE
#=================================================
ynh_script_progression "Restoring the MySQL database..."
ynh_mysql_db_shell < ./db.sql
#=================================================
# RESTORE THE PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression "Restoring the PHP-FPM configuration..."
# Restore the file first, so it can have a backup if different
ynh_restore "/etc/php/$php_version/fpm/pool.d/$app.conf"
# Recreate a dedicated php-fpm config
ynh_config_add_phpfpm
ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore "/etc/cron.d/$app"
ynh_restore "/etc/fail2ban/jail.d/$app.conf"
ynh_restore "/etc/fail2ban/filter.d/$app.conf"
ynh_systemctl --action=restart --service=fail2ban
#=================================================
# RELOAD NGINX AND PHP-FPM
#=================================================
ynh_script_progression "Reloading NGINX web server and PHP-FPM..."
ynh_systemctl --service=php$php_version-fpm --action=reload
ynh_systemctl --service=nginx --action=reload
#=================================================
# DEACTIVE MAINTENANCE MODE
#=================================================
ynh_maintenance_mode_OFF
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression "Restoration completed for $app"