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
|
|
|
|
sudo cp ../settings/scripts/_common.sh ./_common.sh
|
|
|
|
sudo chmod a+rx _common.sh
|
|
|
|
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)
|
|
|
|
final_path="/var/www/${app}"
|
|
|
|
db_name=$(ynh_app_setting_get $app db_name)
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STANDARD BACKUP STEPS
|
|
|
|
#=================================================
|
|
|
|
# BACKUP APP MAIN DIR
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
CHECK_SIZE "$final_path"
|
|
|
|
ynh_backup "$final_path" "sources"
|
|
|
|
|
|
|
|
|
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}"
|
|
|
|
CHECK_SIZE "$DATADIR"
|
|
|
|
ynh_backup "$DATADIR" "data" 1
|
|
|
|
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
|
|
|
|
#=================================================
|
|
|
|
ynh_backup "/etc/fail2ban/jail.d/$app.conf" "jaild.conf"
|
|
|
|
ynh_backup "/etc/fail2ban/filter.d/$app.conf" "filterd.conf"
|
|
|
|
|
2017-06-03 18:13:29 +02:00
|
|
|
#=================================================
|
|
|
|
# BACKUP NGINX CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" "nginx.conf"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# BACKUP PHP-FPM CONFIGURATION
|
|
|
|
#=================================================
|
2016-09-11 10:16:37 +02:00
|
|
|
|
2017-06-03 18:13:29 +02:00
|
|
|
ynh_backup "/etc/php5/fpm/pool.d/$app.conf" "php-fpm.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-06-03 18:13:29 +02:00
|
|
|
ynh_mysql_dump_db "$db_name" > dump.sql
|
|
|
|
CHECK_SIZE "dump.sql"
|
|
|
|
ynh_backup "dump.sql" "db.sql"
|