2017-02-13 20:43:41 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2018-01-30 23:44:49 +01:00
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
2017-07-21 22:28:49 +02:00
|
|
|
source /usr/share/yunohost/helpers
|
2017-02-13 20:43:41 +01:00
|
|
|
|
2017-07-21 22:28:49 +02:00
|
|
|
# Stop script if errors
|
|
|
|
ynh_abort_if_errors
|
2017-02-13 20:43:41 +01:00
|
|
|
|
2017-07-21 22:28:49 +02:00
|
|
|
# Import common cmd
|
|
|
|
source ../settings/scripts/psql.sh
|
2018-01-25 19:33:20 +01:00
|
|
|
source ../settings/scripts/experimental_helper.sh
|
|
|
|
source ../settings/scripts/_common.sh
|
2017-02-13 20:43:41 +01:00
|
|
|
|
2018-01-30 23:44:49 +01:00
|
|
|
#=================================================
|
|
|
|
# SET ALL CONSTANT
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
synapse_user="matrix-$app"
|
|
|
|
synapse_db_name="matrix_$app"
|
|
|
|
synapse_db_user="matrix_$app"
|
|
|
|
upstream_version=$(ynh_app_upstream_version)
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# LOAD SETTINGS
|
|
|
|
#=================================================
|
|
|
|
|
2017-07-21 22:28:49 +02:00
|
|
|
domain=$(ynh_app_setting_get $app special_domain)
|
2018-02-12 10:49:11 +01:00
|
|
|
final_path=$(ynh_app_setting_get $app final_path)
|
2017-02-13 20:43:41 +01:00
|
|
|
|
2018-01-30 23:44:49 +01:00
|
|
|
#=================================================
|
|
|
|
# STANDARD BACKUP STEPS
|
|
|
|
#=================================================
|
|
|
|
# BACKUP THE NGINX CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
|
2018-02-12 18:13:44 +01:00
|
|
|
ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
2017-02-13 20:43:41 +01:00
|
|
|
|
2018-01-30 23:44:49 +01:00
|
|
|
#=================================================
|
|
|
|
# BACKUP SYNAPSE CONFIG
|
|
|
|
#=================================================
|
|
|
|
|
2018-02-12 18:13:44 +01:00
|
|
|
ynh_backup "/etc/matrix-$app"
|
2017-02-13 20:43:41 +01:00
|
|
|
|
2018-01-30 23:44:49 +01:00
|
|
|
#=================================================
|
|
|
|
# BACKUP SYSTEMD
|
|
|
|
#=================================================
|
2017-10-21 01:31:04 +02:00
|
|
|
|
2018-01-19 22:05:39 +01:00
|
|
|
ynh_backup "/etc/default/matrix-$app"
|
|
|
|
ynh_backup "/etc/systemd/system/matrix-$app.service"
|
|
|
|
ynh_backup "/etc/default/coturn-$app"
|
|
|
|
ynh_backup "/etc/systemd/system/coturn-$app.service"
|
2017-10-21 01:31:04 +02:00
|
|
|
|
2018-01-30 23:44:49 +01:00
|
|
|
#=================================================
|
|
|
|
# BACKUP THE APP MAIN DIR
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_backup "$final_path" "bin"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# BACKUP SYNAPSE DATA
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_backup "/var/lib/matrix-$app" "data" 1
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# BACKUP THE POSTGRESQL DATABASE
|
|
|
|
#=================================================
|
|
|
|
|
2018-02-12 10:49:11 +01:00
|
|
|
ynh_psql_dump_db "$synapse_db_name" > ${YNH_CWD}/dump.sql
|
2018-01-30 23:44:49 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# BACKUP SYNAPSE LOG
|
|
|
|
#=================================================
|
|
|
|
|
2019-02-12 21:24:25 +01:00
|
|
|
ynh_backup "/var/log/matrix-$app"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# BACKUP FAIL2BAN CONFIG
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_backup "/etc/fail2ban/jail.d/$app.conf"
|
|
|
|
ynh_backup "/etc/fail2ban/filter.d/$app.conf"
|