1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/thelounge_ynh.git synced 2024-09-03 20:35:54 +02:00
thelounge_ynh/scripts/backup

87 lines
3.1 KiB
Text
Raw Normal View History

2019-02-23 11:06:32 +01:00
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
2019-10-25 11:04:41 +02:00
ynh_script_progression --message="Loading installation settings..." --time --weight=1
2019-02-23 11:06:32 +01:00
app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get $app final_path)
config_path=$(ynh_app_setting_get $app config_path)
domain=$(ynh_app_setting_get $app domain)
#=================================================
# STANDARD BACKUP STEPS
2019-10-25 11:04:41 +02:00
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --time --weight=1
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
2019-02-23 11:06:32 +01:00
#=================================================
# BACKUP THE APP MAIN DIR
#=================================================
2019-10-25 11:04:41 +02:00
ynh_script_progression --message="Backing up the main app directory..." --time --weight=1
2019-02-23 11:06:32 +01:00
2019-10-25 11:04:41 +02:00
ynh_backup --src_path="$final_path"
2019-02-23 11:06:32 +01:00
#=================================================
# BACKUP THE NGINX CONFIGURATION
#=================================================
2019-10-25 11:04:41 +02:00
ynh_script_progression --message="Backing up nginx web server configuration..." --time --weight=1
2019-02-23 11:06:32 +01:00
2019-10-25 11:04:41 +02:00
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
2019-02-23 11:06:32 +01:00
#=================================================
# SPECIFIC BACKUP
#=================================================
# BACKUP LOGROTATE
#=================================================
2019-10-25 11:04:41 +02:00
ynh_script_progression --message="Backing up logrotate configuration..." --time --weight=1
2019-02-23 11:06:32 +01:00
2019-10-25 11:04:41 +02:00
ynh_backup --src_path="/etc/logrotate.d/$app"
2019-02-23 11:06:32 +01:00
#=================================================
# BACKUP SYSTEMD
#=================================================
2019-10-25 11:04:41 +02:00
ynh_script_progression --message="Backing up systemd configuration..." --time --weight=1
2019-02-23 11:06:32 +01:00
2019-10-25 11:04:41 +02:00
ynh_backup --src_path="/etc/systemd/system/$app.service"
2019-02-23 11:06:32 +01:00
#=================================================
# BACKUP CONFIG
#=================================================
2019-10-25 11:04:41 +02:00
ynh_script_progression --message="Backing up config path..." --time --weight=1
ynh_backup --src_path="$config_path"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --time --weight=1
2019-02-23 11:06:32 +01:00
2019-10-25 11:04:41 +02:00
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
2019-02-23 11:06:32 +01:00
#=================================================
# END OF SCRIPT
#=================================================
2019-10-25 11:04:41 +02:00
ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --time --last