1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/monitorix_ynh.git synced 2024-09-03 19:46:06 +02:00

Implement backup core only

This commit is contained in:
Josué Tille 2022-11-02 23:07:44 +01:00
parent 174b348052
commit 680101f2f7
No known key found for this signature in database
GPG key ID: 716A6C99B04194EF
5 changed files with 62 additions and 15 deletions

View file

@ -1,3 +1,38 @@
### Upgrade
By default, a backup is performed before upgrading. To avoid this, you have the following options:
- Pass the `NO_BACKUP_UPGRADE` env variable with `1` at each upgrade. For example `NO_BACKUP_UPGRADE=1 yunohost app upgrade monitorix`.
- Set `disable_backup_before_upgrade` to `1`. You can set it with this command:
`yunohost app setting monitorix disable_backup_before_upgrade -v 1`
After that, the settings will be applied for **all** the next updates.
From command line:
`yunohost app upgrade monitorix`
### Backup
This application now uses the core-only feature of the backup. To keep the integrity of the data and to have a better guarantee of the restoration it is recommended to proceed as follows:
- Stop Gitea service with this command:
`systemctl stop monitorix.service`
- Launch Gitea backup with this command:
`yunohost backup create --app monitorix`
- Backup your data with your specific strategy (could be with rsync, borg backup or just cp). The data is generally stored in `/var/lib/monitorix`.
- Restart Gitea service with theses command:
`systemctl start monitorix.service`
### Remove
Due of the backup core only feature the data directory in `/var/lib/monitorix` **is not removed**. It must be manually deleted to purge user data from the app.
### More sensor ### More sensor
If you want to see the temperature of some sensor you can install the `lm-sensor` packet. For disk temperature you can instal the `hddtemp` packet. If you want to see the temperature of some sensor you can install the `lm-sensor` packet. For disk temperature you can instal the `hddtemp` packet.

View file

@ -18,6 +18,10 @@ ynh_abort_if_errors
ynh_print_info --message="Loading installation settings..." ynh_print_info --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
#================================================= #=================================================
@ -36,6 +40,6 @@ ynh_backup --src_path "/etc/monitorix"
# Copy Monitorix data # Copy Monitorix data
ynh_print_info --message="Backing up data..." ynh_print_info --message="Backing up data..."
ynh_backup --src_path "/var/lib/monitorix" ynh_backup --src_path "/var/lib/monitorix" --is_big=1
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -22,6 +22,12 @@ path_url=$YNH_APP_ARG_PATH
ynh_webpath_register $app $domain $path_url ynh_webpath_register $app $domain $path_url
if [ -e "/var/lib/monitorix" ]; then
old_data_dir_path="/var/lib/monitorix$(date '+%Y%m%d.%H%M%S')"
ynh_print_warn "A data directory already exist. Data was renamed to $old_data_dir_path"
mv "/var/lib/monitorix" "$old_data_dir_path"
fi
# Find a port for built-in monitorix HTTP server # Find a port for built-in monitorix HTTP server
ynh_script_progression --message="Finding available ports..." ynh_script_progression --message="Finding available ports..."
port=$(ynh_find_port --port 8080) port=$(ynh_find_port --port 8080)

View file

@ -33,8 +33,7 @@ ynh_mysql_drop_db "$dbname" || true
ynh_mysql_drop_user "$dbuser" || true ynh_mysql_drop_user "$dbuser" || true
# Remove data # Remove data
ynh_script_progression --message="Removing logs..." ynh_print_info --message="Due of the backup core only feature the data directory in '/var/lib/monitorix' was not removed. It need to be removed manually to purge app user data."
ynh_secure_remove --file=/var/lib/monitorix
# Remove nginx config # Remove nginx config
ynh_secure_remove --file="/etc/nginx/conf.d/monitorix_status.conf" ynh_secure_remove --file="/etc/nginx/conf.d/monitorix_status.conf"

View file

@ -30,11 +30,14 @@ ynh_script_progression --message="Stoping services..."
systemctl stop monitorix.service systemctl stop monitorix.service
# Backup the current version of the app # Backup the current version of the app
ynh_backup_before_upgrade if [ "0$(ynh_app_setting_get --app=$app --key=disable_backup_before_upgrade)" -ne 1 ]
ynh_clean_setup () { then
# restore it if the upgrade fails ynh_backup_before_upgrade
ynh_restore_upgradebackup ynh_clean_setup () {
} # Clean installation remainings that are not handled by the remove script.
ynh_restore_upgradebackup
}
fi
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors