mirror of
https://github.com/YunoHost-Apps/mailman3_ynh.git
synced 2024-09-03 19:36:17 +02:00
115 lines
3.5 KiB
Bash
Executable file
115 lines
3.5 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
# TODO(decentral1se)
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source ../settings/scripts/_common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# MANAGE SCRIPT FAILURE
|
|
#=================================================
|
|
|
|
ynh_clean_setup () {
|
|
ynh_clean_check_starting
|
|
}
|
|
|
|
ynh_abort_if_errors
|
|
|
|
#=================================================
|
|
# LOAD SETTINGS
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Loading installation settings..." --weight=2
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
|
db_name_app=$(ynh_app_setting_get --app=$app --key=db_name_app)
|
|
db_name_app_web=$(ynh_app_setting_get --app=$app --key=db_name_app_web)
|
|
|
|
#=================================================
|
|
# STANDARD BACKUP STEPS
|
|
#=================================================
|
|
|
|
#=================================================
|
|
# STOP SYSTEMD SERVICE
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Stopping systemd services..." --weight=10
|
|
|
|
ynh_systemd_action --service_name=$app --action=stop
|
|
|
|
ynh_systemd_action --service_name="${app}-web" --action="stop"
|
|
|
|
#=================================================
|
|
# BACKUP THE APP MAIN DIR
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Backing up the main application directory..." --weight=2
|
|
|
|
ynh_backup --src_path=/etc/mailman3/
|
|
|
|
ynh_backup --src_path=/usr/share/mailman3-web
|
|
|
|
#=================================================
|
|
# BACKUP THE NGINX CONFIGURATION
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Backing up NGINX web server configuration..." --weight=2
|
|
|
|
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
|
|
|
#=================================================
|
|
# BACKUP THE POSTGRESQL DATABASE
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Backing up the PostgreSQL databases..." --weight=4
|
|
|
|
ynh_psql_dump_db --database="$db_name_app" > "${app}_db.sql"
|
|
|
|
ynh_psql_dump_db --database="$db_name_app_web" > "${app}_web_db.sql"
|
|
|
|
#=================================================
|
|
# SPECIFIC BACKUP
|
|
#=================================================
|
|
|
|
#=================================================
|
|
# BACKUP SYSTEMD
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Backing up systemd configurations..." --weight=2
|
|
|
|
ynh_backup --src_path="/etc/systemd/system/multi-user.target.wants/$app.service"
|
|
|
|
ynh_backup --src_path="/etc/systemd/system/multi-user.target.wants/${app}-web.service"
|
|
|
|
#=================================================
|
|
# BACKUP A CRON FILE
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Backing up crontab configuration..." --weight=2
|
|
|
|
ynh_backup --src_path="/etc/cron.d/$app"
|
|
|
|
#=================================================
|
|
# START SYSTEMD SERVICE
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Starting systemd services..." --weight=1
|
|
|
|
ynh_systemd_action --action=start --service_name=$app
|
|
|
|
ynh_systemd_action --action=start --service_name="${app}-web"
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Backup script completed for $app" --last
|