1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/synapse_ynh.git synced 2024-09-03 20:26:38 +02:00
synapse_ynh/scripts/backup
2018-07-18 10:09:14 +02:00

81 lines
No EOL
2.3 KiB
Bash

#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source /usr/share/yunohost/helpers
# Stop script if errors
ynh_abort_if_errors
# Import common cmd
source ../settings/scripts/psql.sh
source ../settings/scripts/experimental_helper.sh
source ../settings/scripts/_common.sh
#=================================================
# 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
#=================================================
domain=$(ynh_app_setting_get $app special_domain)
final_path=$(ynh_app_setting_get $app final_path)
#=================================================
# STANDARD BACKUP STEPS
#=================================================
# BACKUP THE NGINX CONFIGURATION
#=================================================
ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf"
#=================================================
# BACKUP SYNAPSE CONFIG
#=================================================
ynh_backup "/etc/matrix-$app"
#=================================================
# BACKUP SYSTEMD
#=================================================
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"
#=================================================
# 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
#=================================================
ynh_psql_dump_db "$synapse_db_name" > ${YNH_CWD}/dump.sql
#=================================================
# BACKUP SYNAPSE LOG
#=================================================
ynh_backup "/var/log/matrix-$app"