From 4faefcecab3077890e1e9cb0e60938e4709de35d Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Holcroft Date: Mon, 30 Oct 2017 12:48:42 +0100 Subject: [PATCH] Restructure backup script --- scripts/backup | 55 ++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 13 deletions(-) diff --git a/scripts/backup b/scripts/backup index b2c5ea4..c990ea4 100644 --- a/scripts/backup +++ b/scripts/backup @@ -1,32 +1,61 @@ #!/bin/bash -# Source local helpers -source ./_common.sh -# Source app helpers +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source _common.sh source /usr/share/yunohost/helpers -# Abort script if errors +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +# Exit if an error occurs during the execution of the script ynh_abort_if_errors +#================================================= +# LOAD SETTINGS +#================================================= + # Set app specific variables app=$YNH_APP_INSTANCE_NAME -dbname=$app -dbuser=$app +db_name=$app # Retrieve app settings domain=$(ynh_app_setting_get "$app" domain) -path=$(ynh_app_setting_get "$app" path) -dbpass=$(ynh_app_setting_get "$app" mysqlpwd) +path_url=$(ynh_app_setting_get "$app" path) +final_path=$(ynh_app_setting_get "$app" final_path) + +#================================================= +# STANDARD BACKUP STEPS +#================================================= +# BACKUP THE APP MAIN DIR +#================================================= + +# Clean cache files before backup +ynh_secure_remove "${final_path}/web/var/cache/"{profiler,twig}/* -# Copy the app files -final_path="/var/www/$app" ynh_backup "$final_path" -# Copy the conf files +#================================================= +# BACKUP THE NGINX CONFIGURATION +#================================================= + ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" + +#================================================= +# BACKUP THE PHP-FPM CONFIGURATION +#================================================= + ynh_backup "/etc/php5/fpm/pool.d/${app}.conf" +#================================================= +# BACKUP THE MYSQL DATABASE +#================================================= + # Dump the database -mysqldump -u "$dbuser" -p"$dbpass" --no-create-db "$dbname" > ./dump.sql -ynh_backup ./dump.sql +ynh_mysql_dump_db "$db_name" > db.sql