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

108 lines
3.8 KiB
Text
Raw Normal View History

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
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
domain=$(ynh_app_setting_get --app=$app --key=special_domain)
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"
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-04-30 19:15:33 +02:00
ynh_backup --src_path="/var/lib/matrix-$app" --is_big
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-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