2017-06-10 10:10:31 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2018-12-24 16:25:49 +01:00
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
2017-06-10 10:10:31 +02:00
|
|
|
|
2018-12-25 19:32:44 +01:00
|
|
|
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
|
2018-12-25 21:03:39 +01:00
|
|
|
mkdir ./upgrade.d
|
|
|
|
mkdir ../conf
|
2018-12-25 19:41:43 +01:00
|
|
|
cp ../settings/scripts/upgrade.d/upgrade.sh ./upgrade.d/upgrade.sh
|
2018-12-25 19:51:27 +01:00
|
|
|
cp ../settings/conf/*.default ../conf/
|
2018-12-25 19:32:44 +01:00
|
|
|
chmod a+rx _common.sh upgrade.d/upgrade.sh
|
|
|
|
fi
|
|
|
|
|
2017-06-10 10:10:31 +02:00
|
|
|
# Source YunoHost helpers
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
2018-12-24 16:25:49 +01:00
|
|
|
# Load common variables and helpers
|
2018-12-25 19:32:44 +01:00
|
|
|
source _common.sh
|
2018-12-24 16:25:49 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# MANAGE SCRIPT FAILURE
|
|
|
|
#=================================================
|
|
|
|
|
2018-12-25 20:55:11 +01:00
|
|
|
ynh_clean_setup () {
|
|
|
|
|
|
|
|
rm /var/opt/gitlab/backups/*_gitlab_backup.tar
|
|
|
|
true
|
|
|
|
}
|
|
|
|
|
2018-12-24 16:25:49 +01:00
|
|
|
# Exit if an error occurs during the execution of the script
|
|
|
|
ynh_abort_if_errors
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# LOAD SETTINGS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Copy NGINX configuration
|
2017-06-10 10:10:31 +02:00
|
|
|
domain=$(ynh_app_setting_get "$app" domain)
|
2018-12-24 19:10:30 +01:00
|
|
|
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 "
|
2018-12-24 16:25:49 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STANDARD RESTORATION STEPS
|
|
|
|
#=================================================
|
|
|
|
# RESTORE THE NGINX CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
|
|
|
|
2018-12-24 19:10:30 +01:00
|
|
|
#=================================================
|
2018-12-25 20:55:11 +01:00
|
|
|
# REINSTALL DEPENDENCIES
|
2018-12-24 19:10:30 +01:00
|
|
|
#=================================================
|
|
|
|
|
2018-12-25 19:22:24 +01:00
|
|
|
ynh_install_app_dependencies openssh-server
|
|
|
|
|
2018-12-25 20:55:11 +01:00
|
|
|
#=================================================
|
|
|
|
# RESTORE CONF FILES
|
|
|
|
#=================================================
|
|
|
|
|
2018-12-25 20:08:49 +01:00
|
|
|
ynh_restore_file "$config_path/gitlab-secrets.json"
|
|
|
|
ynh_restore_file "$config_path/gitlab.rb"
|
|
|
|
|
2018-12-25 20:55:11 +01:00
|
|
|
#=================================================
|
|
|
|
# RESTORE THE APP MAIN DIR
|
|
|
|
#=================================================
|
|
|
|
|
2018-12-25 19:22:24 +01:00
|
|
|
setup_source $architecture
|
2018-12-24 19:55:59 +01:00
|
|
|
|
|
|
|
ynh_restore_file "/var/opt/$app/backups/"
|
2018-12-24 19:10:30 +01:00
|
|
|
|
2018-12-24 19:31:51 +01:00
|
|
|
#=================================================
|
2018-12-24 19:55:59 +01:00
|
|
|
# SPECIFIC RESTORATION
|
|
|
|
#=================================================
|
2018-12-25 20:55:11 +01:00
|
|
|
# RESTORE GITLAB DATABASE
|
2018-12-24 19:31:51 +01:00
|
|
|
#=================================================
|
|
|
|
|
2018-12-24 19:55:59 +01:00
|
|
|
fullfile=$(ls /var/opt/gitlab/backups/*_gitlab* --file -c1 | head -1)
|
|
|
|
basename="/var/opt/gitlab/backups/"
|
2018-12-25 20:31:52 +01:00
|
|
|
filename=$(basename -- "$fullfile")
|
2018-12-24 16:25:49 +01:00
|
|
|
last_backup="${filename%_gitlab_backup.tar}"
|
|
|
|
|
2018-12-25 20:55:11 +01:00
|
|
|
gitlab-ctl stop unicorn
|
|
|
|
gitlab-ctl stop sidekiq
|
|
|
|
|
2018-12-24 16:25:49 +01:00
|
|
|
# Use gitlab-rake to backup
|
|
|
|
gitlab-rake gitlab:backup:restore force=yes BACKUP=$last_backup
|
|
|
|
|
|
|
|
gitlab-ctl restart
|
|
|
|
gitlab-rake gitlab:check SANITIZE=true
|
2018-12-25 20:55:11 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALIZATION
|
|
|
|
#=================================================
|
|
|
|
# RELOAD NGINX
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
systemctl reload nginx
|