2016-03-18 18:38:54 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2018-08-14 22:18:22 +02:00
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
2022-01-14 23:57:33 +01:00
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
2016-03-18 18:38:54 +01:00
|
|
|
|
2022-01-14 23:57:33 +01:00
|
|
|
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
2020-11-17 23:55:57 +01:00
|
|
|
source ../settings/scripts/_common.sh
|
2018-08-14 22:18:22 +02:00
|
|
|
source /usr/share/yunohost/helpers
|
2016-03-18 18:38:54 +01:00
|
|
|
|
2022-01-14 23:57:33 +01:00
|
|
|
#=================================================
|
|
|
|
# MANAGE SCRIPT FAILURE
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_clean_setup () {
|
|
|
|
### Remove this function if there's nothing to clean before calling the remove script.
|
|
|
|
true
|
|
|
|
}
|
|
|
|
# Exit if an error occurs during the execution of the script
|
2018-08-14 22:18:22 +02:00
|
|
|
ynh_abort_if_errors
|
2016-03-18 18:38:54 +01:00
|
|
|
|
2022-01-14 23:57:33 +01:00
|
|
|
#=================================================
|
|
|
|
# LOAD SETTINGS
|
|
|
|
#=================================================
|
2020-12-06 21:39:09 +01:00
|
|
|
ynh_print_info --message="Loading installation settings..."
|
2019-06-07 23:09:30 +02:00
|
|
|
|
2022-01-14 23:57:33 +01:00
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
|
|
|
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
|
|
|
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
2016-03-18 18:38:54 +01:00
|
|
|
|
2018-08-14 22:18:22 +02:00
|
|
|
#=================================================
|
2022-01-14 23:57:33 +01:00
|
|
|
# DECLARE DATA AND CONF FILES TO BACKUP
|
2020-12-06 21:39:09 +01:00
|
|
|
#=================================================
|
2022-01-14 23:57:33 +01:00
|
|
|
ynh_print_info --message="Declaring files to be backed up..."
|
2018-08-14 22:18:22 +02:00
|
|
|
|
2022-01-14 23:57:33 +01:00
|
|
|
#=================================================
|
2020-12-14 15:33:36 +01:00
|
|
|
# BACKUP THE NGINX CONFIGURATION
|
2022-01-14 23:57:33 +01:00
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
|
|
|
|
2022-01-15 10:05:56 +01:00
|
|
|
#=================================================
|
|
|
|
# BACKUP LOGROTATE
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_backup --src_path="/etc/logrotate.d/$app"
|
|
|
|
|
2022-01-14 23:57:33 +01:00
|
|
|
#=================================================
|
|
|
|
# BACKUP SOGo CONFIGURATION
|
|
|
|
#=================================================
|
2020-12-06 21:39:09 +01:00
|
|
|
|
2022-01-14 23:57:33 +01:00
|
|
|
ynh_backup --src_path="/etc/$app"
|
2020-12-06 21:39:09 +01:00
|
|
|
|
2022-01-14 23:57:33 +01:00
|
|
|
#=================================================
|
|
|
|
# BACKUP STUNNEL CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_backup --src_path="/etc/stunnel/$app.conf"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# BACKUP CRON
|
|
|
|
#=================================================
|
2018-08-14 22:18:22 +02:00
|
|
|
|
2022-01-14 23:57:33 +01:00
|
|
|
ynh_backup --src_path="/etc/cron.d/$app"
|
2019-06-07 23:09:30 +02:00
|
|
|
|
2022-01-14 23:57:33 +01:00
|
|
|
#=================================================
|
|
|
|
# BACKUP LOGS
|
|
|
|
#=================================================
|
2018-08-14 22:18:22 +02:00
|
|
|
|
2022-01-14 23:57:33 +01:00
|
|
|
ynh_backup --src_path="/var/log/$app"
|
|
|
|
|
|
|
|
#=================================================
|
2018-08-14 22:18:22 +02:00
|
|
|
# BACKUP THE MYSQL DATABASE
|
2022-01-14 23:57:33 +01:00
|
|
|
#=================================================
|
|
|
|
ynh_print_info --message="Backing up the MySQL database..."
|
|
|
|
|
|
|
|
ynh_mysql_dump_db --database="$db_name" > db.sql
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
2019-06-07 23:09:30 +02:00
|
|
|
|
2020-12-06 21:39:09 +01:00
|
|
|
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|