2016-09-11 10:16:37 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Exit on command errors and treat unset variables as an error
|
|
|
|
set -eu
|
|
|
|
|
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-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
|
|
|
|
DATADIR="/home/yunohost.app/${app}"
|
2017-09-11 22:00:57 +02:00
|
|
|
ynh_backup "$DATADIR"
|
2017-06-03 18:13:29 +02:00
|
|
|
else
|
|
|
|
echo "Data dir won't be saved, because backup_core_only is set." >&2
|
|
|
|
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
|