From 5e28392c61d49f13fdd808308c21a167ce61ba4d Mon Sep 17 00:00:00 2001 From: Jimmy Monin Date: Sun, 19 Nov 2017 19:10:47 +0100 Subject: [PATCH] Backup PHP-FPM conf and fix data restoration (fixes #14) --- scripts/backup | 4 ++-- scripts/restore | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/scripts/backup b/scripts/backup index 95d2fa5..2acb428 100644 --- a/scripts/backup +++ b/scripts/backup @@ -42,8 +42,7 @@ ynh_backup "$final_path" backup_core_only=$(ynh_app_setting_get "$app" backup_core_only) if [ -z $backup_core_only ] # If backup_core_only setting set, don't backup data directory then - DATADIR="/home/yunohost.app/${app}" - ynh_backup "$DATADIR" + ynh_backup /home/yunohost.app/${app} else echo "Data dir won't be saved, because backup_core_only is set." >&2 fi @@ -65,6 +64,7 @@ ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= ynh_backup "/etc/php5/fpm/pool.d/$app.conf" +ynh_backup "/etc/php5/fpm/conf.d/20-$app.ini" #================================================= # BACKUP MYSQL DB diff --git a/scripts/restore b/scripts/restore index 225a340..d6f1dc9 100644 --- a/scripts/restore +++ b/scripts/restore @@ -54,9 +54,15 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file "$final_path" # Restore data directory if backed-up -if [ -d "$YNH_BACKUP_DIR/data" ] ; then +if [ -d "$YNH_BACKUP_DIR/apps/${app}/backup/home/yunohost.app/${app}" ] ; then ynh_restore_file "/home/yunohost.app/${app}" +else + # Create app folders + mkdir /home/yunohost.app/${app}/_data /home/yunohost.app/${app}/upload fi +# Remove the option backup_core_only if it's in the settings.yml file +ynh_app_setting_delete $app backup_core_only + #================================================= # RESTORE MYSQL DB #================================================= @@ -76,6 +82,7 @@ ynh_system_user_create $app # Recreate the dedicated user, if not existing #================================================= chown -R $app: $final_path +chown -R $app: /home/yunohost.app/${app} #================================================= # RESTORE FAIL2BAN CONFIGURATION @@ -89,6 +96,7 @@ systemctl restart fail2ban #================================================= ynh_restore_file /etc/php5/fpm/pool.d/$app.conf +ynh_restore_file "/etc/php5/fpm/conf.d/20-$app.ini" #================================================= # GENERIC FINALIZATION