2015-11-18 17:22:55 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2017-09-11 08:29:58 +02:00
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
2017-10-10 13:00:33 +02:00
|
|
|
#=================================================
|
|
|
|
# MANAGE SCRIPT FAILURE
|
|
|
|
#=================================================
|
|
|
|
|
2021-01-11 23:46:48 +01:00
|
|
|
ynh_clean_setup () {
|
|
|
|
ynh_clean_check_starting
|
|
|
|
}
|
2017-10-10 13:00:33 +02:00
|
|
|
# Exit if an error occurs during the execution of the script
|
|
|
|
ynh_abort_if_errors
|
|
|
|
|
2017-09-11 08:29:58 +02:00
|
|
|
#=================================================
|
|
|
|
# LOAD SETTINGS
|
|
|
|
#=================================================
|
2021-01-11 23:46:48 +01:00
|
|
|
ynh_print_info --message="Loading installation settings..."
|
2017-09-11 12:05:16 +02:00
|
|
|
|
2017-09-11 08:29:58 +02:00
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
|
2021-01-11 23:46:48 +01:00
|
|
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
|
|
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
|
|
|
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
2021-09-16 11:39:20 +02:00
|
|
|
data_path=$(ynh_app_setting_get --app=$app --key=data_path)
|
2015-11-18 17:22:55 +01:00
|
|
|
|
2017-09-11 08:29:58 +02:00
|
|
|
#=================================================
|
2021-01-11 23:46:48 +01:00
|
|
|
# DECLARE DATA AND CONF FILES TO BACKUP
|
|
|
|
#=================================================
|
|
|
|
ynh_print_info --message="Declaring files to be backed up..."
|
|
|
|
|
2017-09-11 08:29:58 +02:00
|
|
|
#=================================================
|
|
|
|
# BACKUP THE APP MAIN DIR
|
|
|
|
#=================================================
|
2015-11-18 17:22:55 +01:00
|
|
|
|
2021-01-11 23:46:48 +01:00
|
|
|
ynh_backup --src_path="$final_path"
|
2015-11-18 17:22:55 +01:00
|
|
|
|
2018-01-29 06:45:24 +01:00
|
|
|
#=================================================
|
|
|
|
# BACKUP THE APP DATA
|
|
|
|
#=================================================
|
|
|
|
|
2021-09-16 11:39:20 +02:00
|
|
|
ynh_backup --src_path="$data_path" --is_big
|
2018-01-29 06:45:24 +01:00
|
|
|
|
2017-09-11 08:29:58 +02:00
|
|
|
#=================================================
|
2021-01-11 23:46:48 +01:00
|
|
|
# BACKUP THE NGINX CONFIGURATION
|
2017-09-11 08:29:58 +02:00
|
|
|
#=================================================
|
2015-11-18 17:22:55 +01:00
|
|
|
|
2021-01-11 23:46:48 +01:00
|
|
|
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
2015-11-18 17:22:55 +01:00
|
|
|
|
2017-09-11 08:29:58 +02:00
|
|
|
#=================================================
|
2021-01-11 23:46:48 +01:00
|
|
|
# BACKUP LOGROTATE
|
2017-09-11 08:29:58 +02:00
|
|
|
#=================================================
|
|
|
|
|
2021-01-11 23:46:48 +01:00
|
|
|
ynh_backup --src_path="/etc/logrotate.d/$app"
|
2017-09-11 08:29:58 +02:00
|
|
|
|
|
|
|
#=================================================
|
2017-10-12 12:47:51 +02:00
|
|
|
# BACKUP SYSTEMD
|
2017-09-11 08:29:58 +02:00
|
|
|
#=================================================
|
|
|
|
|
2021-01-11 23:46:48 +01:00
|
|
|
ynh_backup --src_path="/etc/systemd/system/$app.service"
|
|
|
|
|
|
|
|
#=================================================
|
2021-01-14 12:20:53 +01:00
|
|
|
# BACKUP THE DATABASE
|
2021-01-11 23:46:48 +01:00
|
|
|
#=================================================
|
|
|
|
ynh_print_info --message="Backing up the MySQL database..."
|
|
|
|
|
|
|
|
ynh_mysql_dump_db --database="$db_name" > db.sql
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|