diff --git a/scripts/backup b/scripts/backup new file mode 100644 index 0000000..42f6fce --- /dev/null +++ b/scripts/backup @@ -0,0 +1,37 @@ +#!/bin/bash + +# Exit on command errors and treat unset variables as an error +set -eu + +# Source app helpers +source /usr/share/yunohost/helpers + +# Récupère les infos de l'application. +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) + +# Copy the app files +sudo mkdir -p ${backup_dir}/var/www +sudo cp -a $final_path "${backup_dir}/var/www/$app" + +# Backup sources & data +sudo mkdir -p "${backup_dir}/sources" +sudo cp -a $final_path/* $backup_dir/sources + +# Copy Nginx and YunoHost parameters to make the script "standalone" +# Copy the conf files +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 + + +sudo cp -a /etc/systemd/system/${app}.service $backup_dir/ + +# Copie du fichier du cron +sudo cp -a /etc/cron.d/$app $backup_dir/cron_$app