From ce8aeddb0d04fa8e28b7f9551f0393f6f8082343 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Bourr=C3=A9?= Date: Tue, 25 Dec 2018 20:55:11 +0100 Subject: [PATCH] fix restore --- scripts/backup | 13 ++++++++++++- scripts/restore | 29 +++++++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/scripts/backup b/scripts/backup index 917a9ef..fad059a 100644 --- a/scripts/backup +++ b/scripts/backup @@ -16,6 +16,12 @@ source ../settings/scripts/_common.sh # MANAGE SCRIPT FAILURE #================================================= +ynh_clean_setup () { + + rm /var/opt/gitlab/backups/*_gitlab_backup.tar + true +} + # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -35,12 +41,17 @@ domain=$(ynh_app_setting_get "$app" domain) ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= -# BACKUP THE APP MAIN DIR +# BACKUP GITLAB DATABASE #================================================= # Use gitlab-rake to backup gitlab-rake gitlab:backup:create ynh_backup "/var/opt/$app/backups/" + +#================================================= +# BACKUP CONF FILES +#================================================= + ynh_backup "$config_path/gitlab-secrets.json" ynh_backup "$config_path/gitlab.rb" diff --git a/scripts/restore b/scripts/restore index daf9b31..1f7e6c5 100644 --- a/scripts/restore +++ b/scripts/restore @@ -26,6 +26,12 @@ source _common.sh # MANAGE SCRIPT FAILURE #================================================= +ynh_clean_setup () { + + rm /var/opt/gitlab/backups/*_gitlab_backup.tar + true +} + # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -55,14 +61,22 @@ test ! -d $final_path \ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= -# RESTORE THE APP MAIN DIR +# REINSTALL DEPENDENCIES #================================================= ynh_install_app_dependencies openssh-server +#================================================= +# RESTORE CONF FILES +#================================================= + ynh_restore_file "$config_path/gitlab-secrets.json" ynh_restore_file "$config_path/gitlab.rb" +#================================================= +# RESTORE THE APP MAIN DIR +#================================================= + setup_source $architecture ynh_restore_file "/var/opt/$app/backups/" @@ -70,7 +84,7 @@ ynh_restore_file "/var/opt/$app/backups/" #================================================= # SPECIFIC RESTORATION #================================================= -# REINSTALL DEPENDENCIES +# RESTORE GITLAB DATABASE #================================================= fullfile=$(ls /var/opt/gitlab/backups/*_gitlab* --file -c1 | head -1) @@ -78,8 +92,19 @@ basename="/var/opt/gitlab/backups/" filename=$(basename -- "$fullfile") last_backup="${filename%_gitlab_backup.tar}" +gitlab-ctl stop unicorn +gitlab-ctl stop sidekiq + # Use gitlab-rake to backup gitlab-rake gitlab:backup:restore force=yes BACKUP=$last_backup gitlab-ctl restart gitlab-rake gitlab:check SANITIZE=true + +#================================================= +# GENERIC FINALIZATION +#================================================= +# RELOAD NGINX +#================================================= + +systemctl reload nginx \ No newline at end of file