mirror of
https://github.com/YunoHost-Apps/synapse_ynh.git
synced 2024-09-03 20:26:38 +02:00
128 lines
4.4 KiB
Bash
128 lines
4.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
|
|
#=================================================
|
|
|
|
# Exit if an error occurs during the execution of the script
|
|
#REMOVEME? ynh_abort_if_errors
|
|
|
|
#=================================================
|
|
# LOAD SETTINGS
|
|
#=================================================
|
|
#REMOVEME? ynh_print_info --message="Loading installation settings..."
|
|
|
|
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
|
|
|
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
|
|
#REMOVEME? server_name=$(ynh_app_setting_get --app=$app --key=server_name)
|
|
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
|
#REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
|
|
|
if [[ ! "$(systemctl status matrix-$app.service)" =~ "Active: inactive (dead)" ]]; 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 matrix-$app.service'"
|
|
fi
|
|
|
|
#=================================================
|
|
# SET CONSTANTS
|
|
#=================================================
|
|
|
|
synapse_user="matrix-$app"
|
|
synapse_db_name="matrix_$app"
|
|
synapse_db_user="matrix_$app"
|
|
synapse_db_name="matrix_$app"
|
|
upstream_version=$(ynh_app_upstream_version)
|
|
final_www_path="/var/www/$app"
|
|
data_path="/home/yunohost.app/matrix-$app"
|
|
|
|
#=================================================
|
|
# 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="$install_dir"
|
|
ynh_backup --src_path="$final_www_path"
|
|
|
|
#=================================================
|
|
# 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="$synapse_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/default/matrix-$app"
|
|
ynh_backup --src_path="/etc/systemd/system/matrix-$app.service"
|
|
ynh_backup --src_path="/etc/default/coturn-$app"
|
|
ynh_backup --src_path="/etc/systemd/system/coturn-$app.service"
|
|
|
|
#=================================================
|
|
# BACKUP SYNAPSE DATA
|
|
#=================================================
|
|
|
|
ynh_backup --src_path="$data_path" --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)."
|