2017-02-13 20:43:41 +01:00
#!/bin/bash
2018-01-30 23:44:49 +01:00
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
2019-04-30 19:15:33 +02:00
source ../settings/scripts/_common.sh
source ../settings/scripts/experimental_helper.sh
2017-07-21 22:28:49 +02:00
source /usr/share/yunohost/helpers
2017-02-13 20:43:41 +01:00
2019-04-30 19:15:33 +02:00
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
2017-02-13 20:43:41 +01:00
2024-04-08 00:15:16 +02:00
if systemctl is-active $app.service --quiet; then
2024-02-06 20:42:00 +01:00
ynh_print_warn --message="It's hightly recommended to make your backup when the service is stopped. Please stop $app service with this command before to run the backup 'systemctl stop $app.service'"
2020-12-07 16:34:41 +01:00
fi
2022-10-28 10:59:40 +02:00
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
ynh_print_info --message="Declaring files to be backed up..."
2018-01-30 23:44:49 +01:00
#=================================================
2019-04-30 19:15:33 +02:00
# STANDARD BACKUP STEPS
#=================================================
# BACKUP THE APP MAIN DIR
2018-01-30 23:44:49 +01:00
#=================================================
2023-11-01 18:52:07 +01:00
ynh_backup --src_path="$code_dir"
2023-10-31 22:19:40 +01:00
ynh_backup --src_path="$install_dir"
2017-02-13 20:43:41 +01:00
2018-01-30 23:44:49 +01:00
#=================================================
# BACKUP THE NGINX CONFIGURATION
#=================================================
2020-02-22 00:42:32 +01:00
# BACKUP THE PHP-FPM CONFIGURATION
2021-06-26 12:42:14 +02:00
ynh_backup --src_path "/etc/php/$phpversion/fpm/pool.d/$app.conf"
2020-02-22 00:42:32 +01:00
2019-04-30 19:15:33 +02:00
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
2019-12-01 22:18:56 +01:00
if yunohost --output-as plain domain list | grep -q "^$server_name$"
then
ynh_backup --src_path="/etc/nginx/conf.d/${server_name}.d/${app}_server_name.conf"
fi
2017-02-13 20:43:41 +01:00
2018-01-30 23:44:49 +01:00
#=================================================
2019-04-30 19:15:33 +02:00
# BACKUP THE POSTGRESQL DATABASE
2018-01-30 23:44:49 +01:00
#=================================================
2024-02-21 19:24:15 +01:00
ynh_psql_dump_db --database="$db_name" > ${YNH_CWD}/dump.sql
2017-02-13 20:43:41 +01:00
2018-01-30 23:44:49 +01:00
#=================================================
2019-04-30 19:15:33 +02:00
# BACKUP FAIL2BAN CONFIGURATION
2018-01-30 23:44:49 +01:00
#=================================================
2017-10-21 01:31:04 +02:00
2019-04-30 19:15:33 +02:00
ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf"
ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf"
2017-10-21 01:31:04 +02:00
2018-01-30 23:44:49 +01:00
#=================================================
2019-04-30 19:15:33 +02:00
# SPECIFIC BACKUP
#=================================================
# BACKUP SYNAPSE CONFIG
2018-01-30 23:44:49 +01:00
#=================================================
2019-04-30 19:15:33 +02:00
ynh_backup --src_path="/etc/matrix-$app"
2018-01-30 23:44:49 +01:00
#=================================================
2019-04-30 19:15:33 +02:00
# BACKUP SYSTEMD
2018-01-30 23:44:49 +01:00
#=================================================
2024-02-06 20:42:00 +01:00
ynh_backup --src_path="/etc/systemd/system/$app.service"
ynh_backup --src_path="/etc/systemd/system/$app-coturn.service"
2024-02-26 21:20:00 +01:00
ynh_backup --src_path=/etc/systemd/system/$app-sliding-proxy.service
2018-01-30 23:44:49 +01:00
#=================================================
2019-04-30 19:15:33 +02:00
# BACKUP SYNAPSE DATA
2018-01-30 23:44:49 +01:00
#=================================================
2024-02-21 19:24:15 +01:00
ynh_backup --src_path="$data_dir" --is_big=1
2018-01-30 23:44:49 +01:00
#=================================================
# BACKUP SYNAPSE LOG
#=================================================
2021-05-28 02:02:58 +02:00
ynh_backup --src_path="/var/log/matrix-$app" --is_big=1
2019-02-12 21:24:25 +01:00
2019-09-03 15:26:09 +02:00
#=================================================
# BACKUP HOOKS
#=================================================
# Copy hook
ynh_backup --src_path "/etc/yunohost/hooks.d/post_cert_update/50-$app"
2019-02-12 21:24:25 +01:00
#=================================================
2019-04-30 19:15:33 +02:00
# END OF SCRIPT
2019-02-12 21:24:25 +01:00
#=================================================
2020-12-12 15:04:21 +01:00
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."