mirror of
https://github.com/YunoHost-Apps/domoticz_ynh.git
synced 2024-09-03 18:26:17 +02:00
78 lines
3 KiB
Bash
Executable file
78 lines
3 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
|
source ../settings/scripts/_common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#from 2023.1~ynh1
|
|
#End of support for mosquitto. However, we still keep trace of if it was installed in order to be able to back it up and remove it correctly
|
|
mosquitto=$(ynh_app_setting_get --app=$app --key=mosquitto)
|
|
if [[ -z "${mosquitto+x}" ]]; then
|
|
if [[ "$mqtt_domain"="$domain" ]]; then
|
|
ynh_app_setting_set --app="$app" --key=mosquitto --value=0
|
|
else
|
|
ynh_print_warn --message="If you didn't already do it, you should migrate to mosquitto package outside of the app as it will soon not be maintained anymore"
|
|
ynh_app_setting_set --app="$app" --key=mosquitto --value=1
|
|
fi
|
|
fi
|
|
|
|
#=================================================
|
|
# DECLARE DATA AND CONF FILES TO BACKUP
|
|
#=================================================
|
|
ynh_print_info --message="Declaring files to be backed up..."
|
|
|
|
#=================================================
|
|
# BACKUP THE APP MAIN DIR
|
|
#=================================================
|
|
|
|
ynh_backup --src_path="$install_dir"
|
|
|
|
#=================================================
|
|
# BACKUP THE NGINX CONFIGURATION
|
|
#=================================================
|
|
|
|
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
|
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/api_"$app".conf"
|
|
[[ "$mosquitto" = 1 ]] && ynh_print_warn --message="If you didn't already do it, you should migrate to mosquitto package outside of the app as it will soon not be maintained anymore"
|
|
[[ "$mosquitto" = 1 ]] && ynh_backup --src_path="/etc/nginx/conf.d/$mqtt_domain.d/mqtt_$app.conf" --not_mandatory
|
|
|
|
#=================================================
|
|
# SPECIFIC BACKUP
|
|
#=================================================
|
|
# BACKUP LOGROTATE
|
|
#=================================================
|
|
|
|
ynh_backup --src_path="/etc/logrotate.d/$app"
|
|
|
|
#=================================================
|
|
# BACKUP FAIL2BAN CONFIGURATION
|
|
#=================================================
|
|
|
|
ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf"
|
|
ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf"
|
|
|
|
#=================================================
|
|
# BACKUP SYSTEMD
|
|
#=================================================
|
|
|
|
ynh_backup --src_path="/etc/systemd/system/$app.service"
|
|
|
|
#=================================================
|
|
# BACKUP VARIOUS FILES
|
|
#=================================================
|
|
|
|
[[ "$mosquitto" = 1 ]] && ynh_backup --src_path="/etc/mosquitto/conf.d" --not_mandatory
|
|
|
|
ynh_backup --src_path="/usr/share/yunohost/hooks/conf_regen/95-nginx_domoticz"
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|