Implement backup core only

This commit is contained in:
Josué Tille 2020-12-07 15:11:16 +01:00
parent 21b3f33146
commit a857f6c28f
No known key found for this signature in database
GPG Key ID: 716A6C99B04194EF
4 changed files with 54 additions and 12 deletions

View File

@ -68,9 +68,39 @@ Host domain.tld
port 2222 # change this with the port you use port 2222 # change this with the port you use
``` ```
Architecture: this package is compatible with amd64, i386 and arm. The package will try to detect it with the command uname -m and fail if it can't detect the architecture. If that happens please open an issue describing your hardware and the result of the command `uname -m`. Architecture: this package is compatible with amd64, i386 and arm. The package will try to detect it with the command uname -m and fail if it can't detect the architecture. If that happens please open an issue describing your hardware and the result of the command `uname -m`.
### Upgrade
By default a backup is made before the upgrade. To avoid this you have theses following possibilites:
- Pass the `NO_BACKUP_UPGRADE` env variable with `1` at each upgrade. By example `NO_BACKUP_UPGRADE=1 yunohost app upgrade gitea`.
- Set the settings `disable_backup_before_upgrade` to `1`. You can set this with this command:
`yunohost app setting gitea disable_backup_before_upgrade -v 1`
After this settings will be applied for all next upgrade.
### Backup
This app use now the core-only feature of the backup. To keep the integrity of the data and to have a better guarantee of the restoration is recommended to proceed like this:
- Stop gitea service with theses following command:
`systemctl stop gitea.service`
- Launch the backup of gitea with this following command:
`yunohost backup create --app gitea`
- Do a backup of your data with your specific strategy (could be with rsync, borg backup or just cp). The data is generally stored in `/home/gitea`.
- Restart the gitea service with theses command:
`systemctl start gitea.service`
### Remove
Due of the backup core only feature the data directory in `/home/gitea` **is not removed**. It need to be removed manually to purge app user data.
### LFS setup ### LFS setup
To use a repository with an `LFS` setup, you need to activate-it on `/opt/gitea/custom/conf/app.ini` To use a repository with an `LFS` setup, you need to activate-it on `/opt/gitea/custom/conf/app.ini`
```ini ```ini

View File

@ -18,6 +18,10 @@ ynh_abort_if_errors
ynh_script_progression --message="Loading installation settings..." ynh_script_progression --message="Loading installation settings..."
domain=$(ynh_app_setting_get --app $app --key domain) 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 # STANDARD BACKUP STEPS
#================================================= #=================================================
@ -28,7 +32,7 @@ ynh_backup --src_path "$final_path"
# Copy the data files # Copy the data files
ynh_script_progression --message="Backing up user data..." --weight=10 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..." 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 # Delete app directory and configurations
ynh_script_progression --message="Removing code..." ynh_script_progression --message="Removing code..."
ynh_secure_remove --file="$final_path" 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_script_progression --message="Removing logs..."
ynh_secure_remove --file="/var/log/$app" ynh_secure_remove --file="/var/log/$app"
@ -60,4 +58,6 @@ yunohost service remove "$app"
ynh_script_progression --message="Removing fail2ban configuration..." ynh_script_progression --message="Removing fail2ban configuration..."
ynh_remove_fail2ban_config 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 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) port=$(ynh_app_setting_get --app $app --key web_port)
upstream_version=$(ynh_app_setting_get --app $app --key upstream_version) 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_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=10
# 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_backup_before_upgrade
ynh_clean_setup () { ynh_clean_setup () {
# Clean installation remainings that are not handled by the remove script.
ynh_clean_check_starting
ynh_restore_upgradebackup ynh_restore_upgradebackup
} }
fi
# Stop service
ynh_script_progression --message="Stoping services..."
systemctl stop "$app".service
#================================================= #=================================================
# MIGRATION FROM GOGS # MIGRATION FROM GOGS