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

101 lines
3.4 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
if systemctl is-active $app.service --quiet; 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 $app.service'"
2020-12-07 16:34:41 +01:00
fi
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
ynh_print_info --message="Declaring files to be backed up..."
2018-01-30 23:44:49 +01:00
#=================================================
2019-04-30 19:15:33 +02:00
# STANDARD BACKUP STEPS
#=================================================
# BACKUP THE APP MAIN DIR
2018-01-30 23:44:49 +01:00
#=================================================
ynh_backup --src_path="$code_dir"
2023-10-31 22:19:40 +01:00
ynh_backup --src_path="$install_dir"
2017-02-13 20:43:41 +01:00
2018-01-30 23:44:49 +01:00
#=================================================
# BACKUP THE NGINX CONFIGURATION
#=================================================
# BACKUP THE PHP-FPM CONFIGURATION
2021-06-26 12:42:14 +02:00
ynh_backup --src_path "/etc/php/$phpversion/fpm/pool.d/$app.conf"
2019-04-30 19:15:33 +02:00
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
well-known support (#136) * Update README.md * Update manifest.json * a * Delete a * avoid boolean for public but ask a clear choice Yes/No * Update check_process Add server_name="domain2.tld" (DOMAIN) * .well-known DNS conf become optionnal with .well-known edition * .well-known redirection for access by federation Create .well-known redirection for access by federation * .well-known redirection for access by federation If not existing, create .well-known redirection for access by federation * Update README.md back to 0.99.5.2 * back to 0.99.5.2 * back to 0.99.5.2 * back to 0.99.5.2 * Update install * Update upgrade * Update install * Update upgrade * Update install * Update upgrade * Update .well-known redirection for access by federation and applications like Riot.im * Update .well-known redirection for access by federation and applications like Riot.im * update to 1.1.0 * update to 1.1.0 * update to 1.1.0 * update to 1.1.0 * update to 1.1.0 * update to 1.1.0 * Update install * Update upgrade * Update to 1.2.1 * Update to 1.2.1 * Update to 1.2.1 * Back to v1.1.0 * Back to v1.1.0 * Back to v1.1.0 * Update to v1.2.1 * Update to v1.2.1 * Update to v1.2.1 * Important update of upgrade script ynh_replace_string __SERVER_NAME__ $server_name "$homeserver_config_path" was missing * Back to v1.1.0 * Back to v1.1.0 * Back to v1.1.0 * Fix typo for ipv6 validation * Upgrade to v1.2.1 * Upgrade to v1.2.1 * Upgrade to v1.2.1 * remove server_name's nginx conf remove /etc/nginx/conf.d/${server_name}.d/server_name.conf * Create server_name.conf To allow the automatic well-known system for server-name detection instead of DNS record * Update install In # Create .well-known redirection for access by federation change cat > /etc/nginx/conf.d/${server_name}.d/server_name.conf <<EOF location /.well-known/matrix/ { return 200 '{"m.server": "$domain", "m.homeserver": "https://$domain"}'; add_header Content-Type application/json; add_header Access-Control-Allow-Origin '*'; } EOF to cp ../conf/server_name.conf /etc/nginx/conf.d/${server_name}.d/server_name.conf after creation of ../conf/server_name.conf file. * Update upgrade In # Create .well-known redirection for access by federation if it doesn't exist change cat > /etc/nginx/conf.d/${server_name}.d/server_name.conf <<EOF location /.well-known/matrix/ { return 200 '{"m.server": "$domain", "m.homeserver": "https://$domain"}'; add_header Content-Type application/json; add_header Access-Control-Allow-Origin '*'; } EOF to cp ../conf/server_name.conf /etc/nginx/conf.d/${server_name}.d/server_name.conf * backup well.known server_name nginx cond add ynh_backup "/etc/nginx/conf.d/${server_name}.d/server_name.conf" * Backup well.known server-name nging conf add server_name=$(ynh_app_setting_get $app server_name) to make ynh_backup "/etc/nginx/conf.d/${server_name}.d/server_name.conf" understood * Update backup * Update scripts/install Co-Authored-By: Josue-T <josue@tille.ch> * Update install * Update README.md Co-Authored-By: Josue-T <josue@tille.ch> * Update scripts/upgrade Co-Authored-By: Josue-T <josue@tille.ch> * Update conf/server_name.conf Co-Authored-By: Josue-T <josue@tille.ch> * move .well-known redirection to config section move #Create .well-known redirection for access by federation to end of config section * move .well-known redirection to config section move #Create .well-known redirection to the end of config section and Indentation * add checksum management for server_name.conf add checksum management for server_name.conf with the helper ynh_store_file_checksum * add checksum management for server_name.conf add checksum management for server_name.conf with the helper ynh_store_file_checksum * replace __SERVER_NAME__ * replace __SERVER_NAME__ * delete a blank line * Update upgrade * Update install * Update check_process Co-Authored-By: Josue-T <josue@tille.ch> * Update conf/server_name.conf Co-Authored-By: Josue-T <josue@tille.ch> * remove blank line * ynh_store_file_checksum after cp inside if block * change order checksum and cp change order to ynh_backup_if_checksum_is_different then cp then ynh_store_file_checksum * Update install * Update upgrade * Update backup * Update backup * Update scripts/backup Co-Authored-By: Josue-T <josue@tille.ch> * Update scripts/install Co-Authored-By: Josue-T <josue@tille.ch> * Update scripts/install Co-Authored-By: Josue-T <josue@tille.ch> * Update scripts/install Co-Authored-By: Josue-T <josue@tille.ch> * Update install * Update remove * Update upgrade
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
#=================================================
2024-02-21 19:24:15 +01:00
ynh_psql_dump_db --database="$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
#=================================================
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_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
#=================================================
ynh_backup --src_path="/etc/systemd/system/$app.service"
ynh_backup --src_path="/etc/systemd/system/$app-coturn.service"
ynh_backup --src_path=/etc/systemd/system/$app-sliding-proxy.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
#=================================================
2024-02-21 19:24:15 +01:00
ynh_backup --src_path="$data_dir" --is_big=1
2018-01-30 23:44:49 +01:00
#=================================================
# BACKUP SYNAPSE LOG
#=================================================
2021-05-28 02:02:58 +02:00
ynh_backup --src_path="/var/log/matrix-$app" --is_big=1
2019-02-12 21:24:25 +01:00
#=================================================
# BACKUP HOOKS
#=================================================
# 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
#=================================================
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."