2016-09-11 10:16:37 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
2017-06-03 18:13:29 +02:00
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
2016-09-11 10:16:37 +02:00
|
|
|
|
2017-06-03 18:13:29 +02:00
|
|
|
if [ ! -e _common.sh ]; then
|
|
|
|
# Fetch helpers file if not in current directory
|
2017-09-11 22:00:57 +02:00
|
|
|
cp ../settings/scripts/_common.sh ./_common.sh
|
|
|
|
chmod a+rx _common.sh
|
2017-06-03 18:13:29 +02:00
|
|
|
fi
|
|
|
|
source _common.sh
|
2016-09-11 10:16:37 +02:00
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
2017-10-17 19:45:45 +02:00
|
|
|
#=================================================
|
|
|
|
# MANAGE SCRIPT FAILURE
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Exit if an error occurs during the execution of the script
|
|
|
|
ynh_abort_if_errors
|
|
|
|
|
2017-06-03 18:13:29 +02:00
|
|
|
#=================================================
|
|
|
|
# LOAD SETTINGS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
|
|
|
|
domain=$(ynh_app_setting_get $app domain)
|
2017-09-22 21:18:12 +02:00
|
|
|
final_path=$(ynh_app_setting_get "$app" final_path)
|
2017-06-03 18:13:29 +02:00
|
|
|
db_name=$(ynh_app_setting_get $app db_name)
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STANDARD BACKUP STEPS
|
|
|
|
#=================================================
|
|
|
|
# BACKUP APP MAIN DIR
|
|
|
|
#=================================================
|
|
|
|
|
2017-09-11 22:00:57 +02:00
|
|
|
ynh_backup "$final_path"
|
2016-09-11 10:16:37 +02:00
|
|
|
|
|
|
|
# Copy the data directory
|
2017-06-03 18:13:29 +02:00
|
|
|
backup_core_only=$(ynh_app_setting_get "$app" backup_core_only)
|
|
|
|
if [ -z $backup_core_only ] # If backup_core_only setting set, don't backup data directory
|
|
|
|
then
|
2018-01-20 17:25:14 +01:00
|
|
|
ynh_backup /home/yunohost.app/${app}/upload
|
2017-06-03 18:13:29 +02:00
|
|
|
else
|
2017-12-22 20:57:49 +01:00
|
|
|
echo "Data dir won't be saved, because backup_core_only is set." >&2
|
|
|
|
# Remove the option so that next regular backup will be complete
|
|
|
|
ynh_app_setting_delete $app backup_core_only
|
2017-06-03 18:13:29 +02:00
|
|
|
fi
|
|
|
|
|
2017-06-18 18:24:10 +02:00
|
|
|
#=================================================
|
|
|
|
# BACKUP FAIL2BAN CONFIGURATION
|
|
|
|
#=================================================
|
2017-09-11 22:00:57 +02:00
|
|
|
ynh_backup "/etc/fail2ban/jail.d/$app.conf"
|
|
|
|
ynh_backup "/etc/fail2ban/filter.d/$app.conf"
|
2017-06-18 18:24:10 +02:00
|
|
|
|
2017-06-03 18:13:29 +02:00
|
|
|
#=================================================
|
|
|
|
# BACKUP NGINX CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
|
2017-09-11 22:00:57 +02:00
|
|
|
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
|
2017-06-03 18:13:29 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# BACKUP PHP-FPM CONFIGURATION
|
|
|
|
#=================================================
|
2016-09-11 10:16:37 +02:00
|
|
|
|
2017-09-11 22:00:57 +02:00
|
|
|
ynh_backup "/etc/php5/fpm/pool.d/$app.conf"
|
2016-09-11 10:16:37 +02:00
|
|
|
|
2017-06-03 18:13:29 +02:00
|
|
|
#=================================================
|
|
|
|
# BACKUP MYSQL DB
|
|
|
|
#=================================================
|
2017-02-08 18:32:46 +01:00
|
|
|
|
2017-09-11 22:00:57 +02:00
|
|
|
ynh_mysql_dump_db "$db_name" > db.sql
|