2018-02-25 21:45:24 +01:00
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
2020-11-17 23:33:50 +01:00
# Load common variables and helpers
source ../settings/scripts/experimental_helper.sh
source ../settings/scripts/_common.sh
2018-02-25 21:45:24 +01:00
# IMPORT GENERIC HELPERS
source /usr/share/yunohost/helpers
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
# Retrieve app settings
2020-12-08 22:06:19 +01:00
ynh_print_info --message="Loading installation settings..."
2019-06-09 21:05:14 +02:00
domain=$(ynh_app_setting_get --app $app --key domain)
2018-02-25 21:45:24 +01:00
2020-12-07 15:11:16 +01:00
if [[ ! "$(systemctl status $app.service)" =~ "Active: inactive (dead)" ]]; then
ynh_print_warn --message="It's hightly recommended to make your backup when the service is stopped. Please stop $app service and with this command before to run the backup 'systemctl stop $app.service'"
fi
2018-02-25 21:45:24 +01:00
#=================================================
# STANDARD BACKUP STEPS
#=================================================
# Copy the app source files
2020-12-08 22:06:19 +01:00
ynh_print_info --message="Backing up code..."
2019-08-01 14:01:59 +02:00
ynh_backup --src_path "$final_path"
2018-02-25 21:45:24 +01:00
# Copy the data files
2020-12-08 22:06:19 +01:00
ynh_print_info --message="Backing up user data..."
2022-04-23 19:40:27 +02:00
ynh_backup --src_path "$datadir" --is_big=1
2018-02-25 21:45:24 +01:00
2020-12-08 22:06:19 +01:00
ynh_print_info --message="Backing up configuration..."
2019-09-10 22:43:45 +02:00
2018-02-25 21:45:24 +01:00
# Copy the conf files
2019-08-01 14:01:59 +02:00
ynh_backup --src_path "/etc/nginx/conf.d/${domain}.d/${app}.conf"
ynh_backup --src_path "/etc/systemd/system/${app}.service"
2018-02-25 21:45:24 +01:00
# Backup logs
2020-12-08 22:06:19 +01:00
ynh_print_info --message="Backing up logs..."
2019-08-01 14:01:59 +02:00
ynh_backup --src_path "/var/log/$app"
2018-02-25 21:45:24 +01:00
# Dump the database
2020-12-08 22:06:19 +01:00
ynh_print_info --message="Backing up database"
2019-06-09 21:05:14 +02:00
ynh_mysql_dump_db "$dbname" > ./db.sql
2019-10-27 14:54:35 +01:00
2020-12-08 22:06:19 +01:00
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."