#!/bin/bash #================================================= # GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= if [ ! -e _common.sh ]; then # Get the _common.sh file if it's not in the current directory cp ../settings/scripts/_common.sh ./_common.sh mkdir ./upgrade.d mkdir ../conf cp ../settings/scripts/upgrade.d/upgrade.sh ./upgrade.d/upgrade.sh cp ../settings/conf/*.default ../conf/ chmod a+rx _common.sh upgrade.d/upgrade.sh fi # Source YunoHost helpers source /usr/share/yunohost/helpers # Load common variables and helpers 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 #================================================= # LOAD SETTINGS #================================================= # 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 #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # 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/" #================================================= # SPECIFIC RESTORATION #================================================= # RESTORE GITLAB DATABASE #================================================= fullfile=$(ls /var/opt/gitlab/backups/*_gitlab* --file -c1 | head -1) 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