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
|
|
|
|
2019-04-30 19:15:33 +02:00
|
|
|
# Exit if an error occurs during the execution of the script
|
|
|
|
ynh_abort_if_errors
|
2017-02-13 20:43:41 +01:00
|
|
|
|
2018-01-30 23:44:49 +01:00
|
|
|
#=================================================
|
2019-04-30 19:15:33 +02:00
|
|
|
# LOAD SETTINGS
|
2018-01-30 23:44:49 +01:00
|
|
|
#=================================================
|
2019-04-30 19:15:33 +02:00
|
|
|
ynh_script_progression --message="Loading installation settings..." --weight=2
|
2018-01-30 23:44:49 +01:00
|
|
|
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
2019-04-30 19:15:33 +02:00
|
|
|
|
2019-12-14 15:11:33 +01:00
|
|
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
2019-12-01 22:18:56 +01:00
|
|
|
server_name=$(ynh_app_setting_get --app=$app --key=server_name)
|
2019-04-30 19:15:33 +02:00
|
|
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SET CONSTANTS
|
|
|
|
#=================================================
|
|
|
|
|
2018-01-30 23:44:49 +01:00
|
|
|
synapse_user="matrix-$app"
|
|
|
|
synapse_db_name="matrix_$app"
|
|
|
|
synapse_db_user="matrix_$app"
|
|
|
|
upstream_version=$(ynh_app_upstream_version)
|
|
|
|
|
|
|
|
#=================================================
|
2019-04-30 19:15:33 +02:00
|
|
|
# STANDARD BACKUP STEPS
|
|
|
|
#=================================================
|
|
|
|
# BACKUP THE APP MAIN DIR
|
2018-01-30 23:44:49 +01:00
|
|
|
#=================================================
|
2019-04-30 19:15:33 +02:00
|
|
|
ynh_script_progression --message="Backing up the main app directory..." --weight=1
|
2018-01-30 23:44:49 +01:00
|
|
|
|
2019-04-30 19:15:33 +02:00
|
|
|
ynh_backup --src_path="$final_path"
|
2017-02-13 20:43:41 +01:00
|
|
|
|
2018-01-30 23:44:49 +01:00
|
|
|
#=================================================
|
|
|
|
# BACKUP THE NGINX CONFIGURATION
|
|
|
|
#=================================================
|
2019-04-30 19:15:33 +02:00
|
|
|
ynh_script_progression --message="Backing up nginx web server configuration..." --weight=1
|
2018-01-30 23:44:49 +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
|
|
|
#=================================================
|
2019-04-30 19:15:33 +02:00
|
|
|
ynh_script_progression --message="Backing up the PostgreSQL database..." --weight=2
|
2018-01-30 23:44:49 +01:00
|
|
|
|
2019-04-30 19:15:33 +02:00
|
|
|
ynh_psql_dump_db --database="$synapse_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
|
|
|
#=================================================
|
2019-04-30 19:15:33 +02:00
|
|
|
ynh_script_progression --message="Backing up fail2ban configuration" --weight=1
|
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_script_progression --message="Backing up synapse configuration..." --weight=2
|
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
|
|
|
#=================================================
|
2019-04-30 19:15:33 +02:00
|
|
|
ynh_script_progression --message="Backing up systemd configuration..." --weight=1
|
2018-01-30 23:44:49 +01:00
|
|
|
|
2019-04-30 19:15:33 +02:00
|
|
|
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"
|
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
|
|
|
#=================================================
|
2019-04-30 19:15:33 +02:00
|
|
|
ynh_script_progression --message="Backing up synapse data..." --weight=1
|
2018-01-30 23:44:49 +01:00
|
|
|
|
2019-06-09 21:33:18 +02:00
|
|
|
ynh_backup --src_path="/var/lib/matrix-$app"
|
2018-01-30 23:44:49 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# BACKUP SYNAPSE LOG
|
|
|
|
#=================================================
|
2019-04-30 19:15:33 +02:00
|
|
|
ynh_script_progression --message="Backing up synapse log..." --weight=1
|
2018-01-30 23:44:49 +01:00
|
|
|
|
2019-04-30 19:15:33 +02:00
|
|
|
ynh_backup --src_path="/var/log/matrix-$app"
|
2019-02-12 21:24:25 +01:00
|
|
|
|
2019-09-03 15:26:09 +02:00
|
|
|
#=================================================
|
|
|
|
# BACKUP HOOKS
|
|
|
|
#=================================================
|
2019-11-01 20:32:46 +01:00
|
|
|
ynh_script_progression --message="Backing up synapse hook..." --weight=1
|
2019-09-03 15:26:09 +02:00
|
|
|
|
|
|
|
# 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
|
|
|
#=================================================
|
|
|
|
|
2019-04-30 19:15:33 +02:00
|
|
|
ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last
|