1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/osjs_ynh.git synced 2024-09-03 19:56:11 +02:00

Update backup

This commit is contained in:
frju365 2017-08-07 01:07:01 +02:00 committed by GitHub
parent 365d36daf2
commit b48d24b176

View file

@ -3,35 +3,48 @@
# Exit on command errors and treat unset variables as an error # Exit on command errors and treat unset variables as an error
set -eu set -eu
# Source app helpers #=================================================
# IMPORT GENERIC HELPERS
#=================================================
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
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
# Récupère les infos de l'application. #=================================================
# LOAD SETTINGS
#=================================================
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
# The parameter $1 is the backup directory location dedicated to the app
backup_dir=$YNH_APP_BACKUP_DIR
final_path=$(ynh_app_setting_get $app final_path)
domain=$(ynh_app_setting_get $app domain) domain=$(ynh_app_setting_get $app domain)
final_path=$(ynh_app_setting_get $app final_path)
# Copy the app files #=================================================
sudo mkdir -p ${backup_dir}/var/www # STANDARD BACKUP STEPS
sudo cp -a $final_path "${backup_dir}/var/www/$app" #=================================================
# BACKUP APP MAIN DIR
#=================================================
# Backup sources & data CHECK_SIZE "$final_path"
sudo mkdir -p "${backup_dir}/sources" ynh_backup "$final_path" "sources"
sudo cp -a $final_path/* $backup_dir/sources
# Copy Nginx and YunoHost parameters to make the script "standalone" #=================================================
# Copy the conf files # BACKUP NGINX CONFIGURATION
sudo mkdir -p "${backup_dir}/conf" #=================================================
sudo cp -a /etc/nginx/conf.d/$domain.d/$app.conf "${backup_dir}/conf/nginx.conf"
sudo mkdir -p "${backup_dir}/yunohost"
sudo cp -a /etc/yunohost/apps/$app/. $backup_dir/yunohost
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" "nginx.conf"
sudo cp -a /etc/systemd/system/${app}.service $backup_dir/ #=================================================
# BACKUP LOGROTATE CONFIGURATION
#=================================================
ynh_backup "/etc/logrotate.d/$app" "logrotate"
# Copie du fichier du cron #=================================================
sudo cp -a /etc/cron.d/$app $backup_dir/cron_$app # BACKUP SYSTEMD CONFIGURATION
#=================================================
ynh_backup "/etc/systemd/system/$app.service" "systemd.service"