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:
parent
174b348052
commit
680101f2f7
5 changed files with 62 additions and 15 deletions
|
@ -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
|
||||
|
||||
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.
|
||||
|
@ -26,8 +61,8 @@ priority = 5
|
|||
<lmsens>
|
||||
<list>
|
||||
core0 = temp1
|
||||
core1 =
|
||||
mb0 =
|
||||
core1 =
|
||||
mb0 =
|
||||
cpu0 =
|
||||
fan0 =
|
||||
fan1 =
|
||||
|
@ -35,13 +70,13 @@ priority = 5
|
|||
volt0 =
|
||||
volt1 =
|
||||
volt2 =
|
||||
volt3 =
|
||||
volt3 =
|
||||
volt4 =
|
||||
volt5 =
|
||||
volt6 =
|
||||
volt5 =
|
||||
volt6 =
|
||||
volt7 =
|
||||
</list>
|
||||
</lmsns>
|
||||
</lmsns>
|
||||
|
||||
# GENSENS graph
|
||||
# -----------------------------------------------------------------------------
|
||||
|
@ -100,7 +135,7 @@ priority = 5
|
|||
<list>
|
||||
0 = /, /home, /var, /$tempdir, swap
|
||||
</list>
|
||||
<desc>
|
||||
<desc>
|
||||
/ = Root FS
|
||||
/home = home
|
||||
/var = var
|
||||
|
|
|
@ -18,6 +18,10 @@ ynh_abort_if_errors
|
|||
ynh_print_info --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
|
||||
#=================================================
|
||||
|
@ -36,6 +40,6 @@ ynh_backup --src_path "/etc/monitorix"
|
|||
|
||||
# Copy Monitorix 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)."
|
||||
|
|
|
@ -22,6 +22,12 @@ path_url=$YNH_APP_ARG_PATH
|
|||
|
||||
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
|
||||
ynh_script_progression --message="Finding available ports..."
|
||||
port=$(ynh_find_port --port 8080)
|
||||
|
|
|
@ -33,8 +33,7 @@ ynh_mysql_drop_db "$dbname" || true
|
|||
ynh_mysql_drop_user "$dbuser" || true
|
||||
|
||||
# Remove data
|
||||
ynh_script_progression --message="Removing logs..."
|
||||
ynh_secure_remove --file=/var/lib/monitorix
|
||||
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."
|
||||
|
||||
# Remove nginx config
|
||||
ynh_secure_remove --file="/etc/nginx/conf.d/monitorix_status.conf"
|
||||
|
|
|
@ -30,11 +30,14 @@ ynh_script_progression --message="Stoping services..."
|
|||
systemctl stop monitorix.service
|
||||
|
||||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
ynh_clean_setup () {
|
||||
# restore it if the upgrade fails
|
||||
ynh_restore_upgradebackup
|
||||
}
|
||||
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_restore_upgradebackup
|
||||
}
|
||||
fi
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
|
|
Loading…
Reference in a new issue