Implement backup core only

This commit is contained in:
Josué Tille
2020-12-07 15:11:16 +01:00
parent 21b3f33146
commit a857f6c28f
4 changed files with 54 additions and 12 deletions

View File

@ -18,6 +18,10 @@ ynh_abort_if_errors
ynh_script_progression --message="Loading installation settings..."
domain=$(ynh_app_setting_get --app $app --key domain)
if [[ ! "$(systemctl status $app.service)" =~ "Active: inactive (dead)" ]]; then
ynh_print_warn --message="It's hightly recommended to make your backup when the service is stopped. Please stop $app service and with this command before to run the backup 'systemctl stop $app.service'"
fi
#=================================================
# STANDARD BACKUP STEPS
#=================================================
@ -28,7 +32,7 @@ ynh_backup --src_path "$final_path"
# Copy the data files
ynh_script_progression --message="Backing up user data..." --weight=10
ynh_backup --src_path "$DATADIR"
ynh_backup --src_path "$DATADIR" --is_big=1
ynh_script_progression --message="Backing up configuration..."

View File

@ -32,8 +32,6 @@ ynh_mysql_drop_user "$dbuser" 2>/dev/null
# Delete app directory and configurations
ynh_script_progression --message="Removing code..."
ynh_secure_remove --file="$final_path"
ynh_script_progression --message="Removing user data..."
ynh_secure_remove --file="$DATADIR"
ynh_script_progression --message="Removing logs..."
ynh_secure_remove --file="/var/log/$app"
@ -60,4 +58,6 @@ yunohost service remove "$app"
ynh_script_progression --message="Removing fail2ban configuration..."
ynh_remove_fail2ban_config
ynh_print_info --message="Due of the backup core only feature the data directory in '$DATADIR' was not removed. It need to be removed manually to purge app user data."
ynh_script_progression --message="Removal of $app completed" --last

View File

@ -25,16 +25,24 @@ is_public=$(ynh_app_setting_get --app $app --key is_public)
port=$(ynh_app_setting_get --app $app --key web_port)
upstream_version=$(ynh_app_setting_get --app $app --key upstream_version)
# Backup the current version of the app
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=10
ynh_backup_before_upgrade
ynh_clean_setup () {
ynh_restore_upgradebackup
}
# Stop service
ynh_script_progression --message="Stoping services..."
systemctl stop "$app".service
# We stop the service before to set ynh_clean_setup
ynh_systemd_action --service_name=$app.service --action=stop
# Backup the current version of the app
if [ "0$(ynh_app_setting_get --app=$app --key=disable_backup_before_upgrade)" -ne 1 ]
then
ynh_backup_before_upgrade
ynh_clean_setup () {
# Clean installation remainings that are not handled by the remove script.
ynh_clean_check_starting
ynh_restore_upgradebackup
}
fi
#=================================================
# MIGRATION FROM GOGS