mirror of
https://github.com/YunoHost-Apps/gitlab_ynh.git
synced 2024-09-03 18:36:35 +02:00
79 lines
2.4 KiB
Bash
79 lines
2.4 KiB
Bash
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
# Source YunoHost helpers
|
|
source /usr/share/yunohost/helpers
|
|
|
|
# Load common variables and helpers
|
|
source ../settings/scripts/_common.sh
|
|
|
|
#=================================================
|
|
# MANAGE SCRIPT FAILURE
|
|
#=================================================
|
|
|
|
# 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"
|
|
|
|
#=================================================
|
|
# RESTORE THE APP MAIN DIR
|
|
#=================================================
|
|
|
|
ynh_restore_file "$final_path"
|
|
|
|
ynh_restore_file "/var/opt/$app/backups/"
|
|
|
|
#=================================================
|
|
# SPECIFIC RESTORATION
|
|
#=================================================
|
|
# REINSTALL DEPENDENCIES
|
|
#=================================================
|
|
|
|
ynh_install_app_dependencies openssh-server
|
|
|
|
ln -s /opt/gitlab/bin/gitlab-ctl /usr/bin/gitlab-ctl
|
|
ln -s /opt/gitlab/bin/gitlab-psql /usr/bin/gitlab-psql
|
|
ln -s /opt/gitlab/bin/gitlab-rails /usr/bin/gitlab-rails
|
|
ln -s /opt/gitlab/bin/gitlab-rake /usr/bin/gitlab-rake
|
|
|
|
fullfile=$(ls /var/opt/gitlab/backups/*_gitlab* --file -c1 | head -1)
|
|
basename="/var/opt/gitlab/backups/"
|
|
last_backup="${filename%_gitlab_backup.tar}"
|
|
|
|
# Use gitlab-rake to backup
|
|
gitlab-rake gitlab:backup:restore force=yes BACKUP=$last_backup
|
|
|
|
ynh_restore_file "$config_path/gitlab-secrets.json"
|
|
ynh_restore_file "$config_path/gitlab.rb"
|
|
|
|
gitlab-ctl restart
|
|
gitlab-rake gitlab:check SANITIZE=true
|