mirror of
https://github.com/YunoHost-Apps/synapse_ynh.git
synced 2024-09-03 20:26:38 +02:00
100 lines
3.4 KiB
Bash
100 lines
3.4 KiB
Bash
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source ../settings/scripts/_common.sh
|
|
source ../settings/scripts/experimental_helper.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# MANAGE SCRIPT FAILURE
|
|
#=================================================
|
|
|
|
if systemctl is-active $app.service --quiet; then
|
|
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'"
|
|
fi
|
|
|
|
#=================================================
|
|
# DECLARE DATA AND CONF FILES TO BACKUP
|
|
#=================================================
|
|
ynh_print_info --message="Declaring files to be backed up..."
|
|
|
|
#=================================================
|
|
# STANDARD BACKUP STEPS
|
|
#=================================================
|
|
# BACKUP THE APP MAIN DIR
|
|
#=================================================
|
|
|
|
ynh_backup --src_path="$code_dir"
|
|
ynh_backup --src_path="$install_dir"
|
|
|
|
#=================================================
|
|
# BACKUP THE NGINX CONFIGURATION
|
|
#=================================================
|
|
|
|
# BACKUP THE PHP-FPM CONFIGURATION
|
|
ynh_backup --src_path "/etc/php/$phpversion/fpm/pool.d/$app.conf"
|
|
|
|
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
|
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
|
|
|
|
#=================================================
|
|
# BACKUP THE POSTGRESQL DATABASE
|
|
#=================================================
|
|
|
|
ynh_psql_dump_db --database="$db_name" > ${YNH_CWD}/dump.sql
|
|
|
|
#=================================================
|
|
# BACKUP FAIL2BAN CONFIGURATION
|
|
#=================================================
|
|
|
|
ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf"
|
|
ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf"
|
|
|
|
#=================================================
|
|
# SPECIFIC BACKUP
|
|
#=================================================
|
|
# BACKUP SYNAPSE CONFIG
|
|
#=================================================
|
|
|
|
ynh_backup --src_path="/etc/matrix-$app"
|
|
|
|
#=================================================
|
|
# BACKUP SYSTEMD
|
|
#=================================================
|
|
|
|
ynh_backup --src_path="/etc/systemd/system/$app.service"
|
|
ynh_backup --src_path="/etc/systemd/system/$app-coturn.service"
|
|
ynh_backup --src_path=/etc/systemd/system/$app-sliding-proxy.service
|
|
|
|
#=================================================
|
|
# BACKUP SYNAPSE DATA
|
|
#=================================================
|
|
|
|
ynh_backup --src_path="$data_dir" --is_big=1
|
|
|
|
#=================================================
|
|
# BACKUP SYNAPSE LOG
|
|
#=================================================
|
|
|
|
ynh_backup --src_path="/var/log/matrix-$app" --is_big=1
|
|
|
|
#=================================================
|
|
# BACKUP HOOKS
|
|
#=================================================
|
|
|
|
# Copy hook
|
|
ynh_backup --src_path "/etc/yunohost/hooks.d/post_cert_update/50-$app"
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|