1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/transmission_ynh.git synced 2024-09-04 01:46:12 +02:00
transmission_ynh/scripts/backup
2017-06-16 20:38:31 +02:00

65 lines
2.2 KiB
Bash

#!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# MANAGE FAILURE OF THE SCRIPT
#=================================================
# Exit on command errors and treat unset variables as an error
set -eu
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
if [ ! -e _common.sh ]; then
# Rapatrie le fichier de fonctions si il n'est pas dans le dossier courant
sudo cp ../settings/scripts/_common.sh ./_common.sh
sudo chmod a+rx _common.sh
fi
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain)
#=================================================
# STANDARD BACKUP STEPS
#=================================================
# BACKUP OF THE NGINX CONFIGURATION
#=================================================
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" "${YNH_APP_BACKUP_DIR}/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# SPECIFIC BACKUP
#=================================================
# BACKUP TRANSMISSION CONFIGURATION
#=================================================
ynh_backup "/etc/transmission-daemon/settings.json" "${YNH_APP_BACKUP_DIR}/etc/transmission-daemon/settings.json"
#=================================================
# BACKUP DATA
#=================================================
CHECK_SIZE "/usr/share/transmission"
ynh_backup "/usr/share/transmission" "${YNH_APP_BACKUP_DIR}/usr/share/transmission"
CHECK_SIZE "/var/lib/transmission-daemon"
ynh_backup "/var/lib/transmission-daemon" "${YNH_APP_BACKUP_DIR}/var/lib/transmission-daemon"
backup_core_only=$(ynh_app_setting_get $app backup_core_only)
if [ -z $backup_core_only ] # Si backup_core_only a une valeur dans le fichier settings.yml, ne sauvegarde pas le dossier data
then
CHECK_SIZE "/home/yunohost.transmission"
ynh_backup "/home/yunohost.transmission" "${YNH_APP_BACKUP_DIR}/home/yunohost.transmission"
else
echo "Data dir will not saved, because backup_core_only is set." >&2
fi