1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/bozon_ynh.git synced 2024-09-03 18:16:09 +02:00
bozon_ynh/scripts/backup

45 lines
1.2 KiB
Text
Raw Normal View History

#!/bin/bash
# to test the functionnality :
# yunohost backup create -n "bozon-test" --ignore-system --apps bozon
# yunohost backup delete bozon-test
2016-03-23 19:30:43 +01:00
if [ ! -e _common.sh ]; then
# Get the _common.sh file if it's not in the current directory
sudo cp ../settings/scripts/_common.sh ./_common.sh
sudo chmod a+rx _common.sh
fi
source _common.sh
2016-10-13 06:51:38 +02:00
source /usr/share/yunohost/helpers
2016-05-23 21:40:55 +02:00
# manage script failure
ynh_abort_if_errors
2016-05-23 21:40:55 +02:00
# retrieve arguments
2016-10-13 06:51:38 +02:00
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get "$app" domain)
2016-03-23 19:30:43 +01:00
2016-04-04 20:01:54 +02:00
# definie useful vars
final_path="/var/www/$app"
data_path="/home/yunohost.app/$app"
nginx_conf="/etc/nginx/conf.d/$domain.d/$app.conf"
phpfpm_conf="/etc/php5/fpm/pool.d/$app.conf"
2016-04-04 20:01:54 +02:00
# backup source & conf files
if [ -e "$final_path" ]; then
myynh_check_disk_space "$final_path"
ynh_backup "$final_path" "source"
fi
[ -e "$nginx_conf" ] && ynh_backup "$nginx_conf" "nginx.conf"
[ -e "$phpfpm_conf" ] && ynh_backup "$phpfpm_conf" "php-fpm.conf"
2016-03-23 19:30:43 +01:00
# backup data
if [ -e "$data_path" ]; then
backup_core_only=$(ynh_app_setting_get "$app" backup_core_only)
if [ $backup_core_only -eq 0 ]; then
myynh_check_disk_space "$data_path"
ynh_backup "$data_path" "data" 1
else
echo "Data dir will not be saved, because backup_core_only is set to true." >&2
fi
fi