mirror of
https://github.com/YunoHost-Apps/adguardhome_ynh.git
synced 2024-09-03 18:06:23 +02:00
Update backup
This commit is contained in:
parent
7536514349
commit
c114b42820
1 changed files with 69 additions and 25 deletions
|
@ -1,33 +1,77 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Exit on command errors and treat unset variables as an error
|
||||
set -eu
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
# See comments in install script
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Source YunoHost helpers
|
||||
#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||
source ../settings/scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
# Backup sources & data
|
||||
# Note: the last argument is where to save this path, see the restore script.
|
||||
ynh_backup "/opt/yunohost/${app}" "sources"
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
### MySQL (remove if not used) ###
|
||||
# If a MySQL database is used:
|
||||
# # Dump the database
|
||||
# dbname=$app
|
||||
# dbuser=$app
|
||||
# dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
|
||||
# mysqldump -u "$dbuser" -p"$dbpass" --no-create-db "$dbname" > ./dump.sql
|
||||
### MySQL end ###
|
||||
ynh_clean_setup () {
|
||||
### Remove this function if there's nothing to clean before calling the remove script.
|
||||
true
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
# Copy NGINX configuration
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "nginx.conf"
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..." --time --weight=1
|
||||
|
||||
### PHP (remove if not used) ###
|
||||
# If a dedicated php-fpm process is used:
|
||||
# # Copy PHP-FPM pool configuration
|
||||
# ynh_backup "/etc/php5/fpm/pool.d/${app}.conf" "php-fpm.conf"
|
||||
### PHP end ###
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
|
||||
domain=$(ynh_app_setting_get --app="$app" --key=domain)
|
||||
|
||||
#=================================================
|
||||
# STANDARD BACKUP STEPS
|
||||
#=================================================
|
||||
# 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"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up the main app directory..." --time --weight=1
|
||||
|
||||
ynh_backup --src_path="$final_path"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up nginx web server configuration..." --time --weight=1
|
||||
|
||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC BACKUP
|
||||
#=================================================
|
||||
# BACKUP SYSTEMD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up systemd configuration..." --time --weight=1
|
||||
|
||||
ynh_backup --src_path="/etc/systemd/system/$app.service"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --time --weight=1
|
||||
|
||||
ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --time --last
|
||||
|
|
Loading…
Reference in a new issue