From ae398110594f02ffc9a4b92b05ae0f6773b82d38 Mon Sep 17 00:00:00 2001 From: frju365 Date: Sun, 11 Mar 2018 13:48:33 +0100 Subject: [PATCH] Update backup --- scripts/backup | 65 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 46 insertions(+), 19 deletions(-) diff --git a/scripts/backup b/scripts/backup index 650723d..f6b6f4f 100644 --- a/scripts/backup +++ b/scripts/backup @@ -1,50 +1,77 @@ #!/bin/bash -# Exit on command errors and treat unset variables as an error -set -eu - +#================================================= +# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= if [ ! -e _common.sh ]; then - # Fetch helpers file if not in current directory - sudo cp ../settings/scripts/_common.sh ./_common.sh - sudo chmod a+rx _common.sh + # Get the _common.sh file if it's not in the current directory + cp ../settings/scripts/_common.sh ./_common.sh + chmod a+rx _common.sh fi source _common.sh source /usr/share/yunohost/helpers +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + #================================================= # LOAD SETTINGS #================================================= app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get $app domain) + final_path=$(ynh_app_setting_get $app final_path) +domain=$(ynh_app_setting_get $app domain) #================================================= # STANDARD BACKUP STEPS #================================================= -# BACKUP APP MAIN DIR +# BACKUP THE MYSQL DATABASE #================================================= -CHECK_SIZE "$final_path" -ynh_backup "$final_path" "sources" +pushd $final_path +mkdir mongo_backup +pushd mongo_backup +mongodump +popd +popd #================================================= -# BACKUP NGINX CONFIGURATION +# BACKUP THE APP MAIN DIR #================================================= -ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" "nginx.conf" +ynh_backup "$final_path" #================================================= -# BACKUP LOGROTATE CONFIGURATION -#================================================= -ynh_backup "/etc/logrotate.d/$app" "logrotate" - -#================================================= -# BACKUP SYSTEMD CONFIGURATION +# BACKUP THE NGINX CONFIGURATION #================================================= -ynh_backup "/etc/systemd/system/$app.service" "systemd.service" +ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" + +#================================================= +# BACKUP THE PHP-FPM CONFIGURATION +#================================================= + +ynh_backup "/etc/php5/fpm/pool.d/$app.conf" +ynh_backup "/etc/php5/fpm/conf.d/20-$app.ini" + +#================================================= +# SPECIFIC BACKUP +#================================================= +# BACKUP LOGROTATE +#================================================= + +ynh_backup "/etc/logrotate.d/$app" + +#================================================= +# BACKUP SYSTEMD +#================================================= + +ynh_backup "/etc/systemd/system/$app.service"