From 1bc5173c78206f73f97b6a15909ad436267e87d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Bourr=C3=A9?= Date: Mon, 24 Dec 2018 19:10:30 +0100 Subject: [PATCH] fix restore --- scripts/backup | 9 +++------ scripts/restore | 28 ++++++++++++++++++++++------ 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/scripts/backup b/scripts/backup index 5fdec5a..60e2900 100644 --- a/scripts/backup +++ b/scripts/backup @@ -16,10 +16,6 @@ source ../settings/scripts/_common.sh # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { - ### Remove this function if there's nothing to clean before calling the remove script. - true -} # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -37,6 +33,7 @@ domain=$(ynh_app_setting_get "$app" domain) #================================================= ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_backup "$final_path" #================================================= # BACKUP THE APP MAIN DIR @@ -45,5 +42,5 @@ ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" # Use gitlab-rake to backup gitlab-rake gitlab:backup:create -ynh_backup "$config_path/gitlab-secrets.json" "gitlab-secrets.json" -ynh_backup "$config_path/gitlab.rb" "gitlab.rb" +ynh_backup "$config_path/gitlab-secrets.json" +ynh_backup "$config_path/gitlab.rb" diff --git a/scripts/restore b/scripts/restore index 277e242..6e42948 100644 --- a/scripts/restore +++ b/scripts/restore @@ -16,10 +16,6 @@ source ../settings/scripts/_common.sh # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { - ### Remove this function if there's nothing to clean before calling the remove script. - true -} # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -29,6 +25,16 @@ ynh_abort_if_errors # Copy NGINX configuration domain=$(ynh_app_setting_get "$app" domain) +path_url=$(ynh_app_setting_get "$app" path_url) + +#================================================= +# CHECK IF THE APP CAN BE RESTORED +#================================================= + +ynh_webpath_available $domain $path_url \ +|| ynh_die "Path not available: ${domain}${path_url}" +test ! -d $final_path \ +|| ynh_die "There is already a directory: $final_path " #================================================= # STANDARD RESTORATION STEPS @@ -42,6 +48,16 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" # RESTORE THE APP MAIN DIR #================================================= +ynh_restore_file "$final_path" + +#================================================= +# SPECIFIC RESTORATION +#================================================= +# REINSTALL DEPENDENCIES +#================================================= + +ynh_install_app_dependencies openssh-server + gitlab-ctl stop unicorn gitlab-ctl stop sidekiq @@ -52,8 +68,8 @@ last_backup="${filename%_gitlab_backup.tar}" # Use gitlab-rake to backup gitlab-rake gitlab:backup:restore force=yes BACKUP=$last_backup -ynh_backup "$config_path/gitlab-secrets.json" "gitlab-secrets.json" -ynh_backup "$config_path/gitlab.rb" "gitlab.rb" +ynh_restore_file "$config_path/gitlab-secrets.json" +ynh_restore_file "$config_path/gitlab.rb" gitlab-ctl restart gitlab-rake gitlab:check SANITIZE=true