diff --git a/tools/app_generator/templates/backup.j2 b/tools/app_generator/templates/backup.j2 index 0a5f28baa0..d96822bc31 100644 --- a/tools/app_generator/templates/backup.j2 +++ b/tools/app_generator/templates/backup.j2 @@ -28,39 +28,60 @@ ynh_print_info --message="Declaring files to be backed up..." {% endif %} {% if data.data_dir -%} -ynh_backup --src_path="$install_dir" -{% endif %} - -{% if data.data_dir -%} +#================================================= +# BACKUP THE DATA DIR +#================================================= {% if data.generator_mode == 'tutorial' -%} +### Only relevant if there is a "data_dir" resource for this app # The --is_big parameters ensure this folder is not included in the backup by default (taking less space), except if BACKUP_CORE_ONLY=0 is passed before the backup command. You might want to document that for your users. +# TODO : there should be an option for this {% endif %} -ynh_backup --src_path="$data_dir" --is_big +ynh_backup --src_path="$data_dir" # --is_big {% endif %} +#================================================= +# SYSTEM CONFIGURATION +#================================================= + +# Backup the nginx configuration ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" {% if data.main_technology == "php" -%} +# Backup the PHP-FPM configuration ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" {% endif %} {% if data.use_fail2ban -%} +# Backup the Fail2Ban config ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf" ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf" {% endif %} {% if data.use_logrotate -%} +# Backup the logrotate configuration ynh_backup --src_path="/etc/logrotate.d/$app" {% endif %} {% if data.main_technology not in ["php", "none"] -%} +# Backup the systemd service unit ynh_backup --src_path="/etc/systemd/system/$app.service" {% endif %} +#================================================= +# BACKUP VARIOUS FILES +#================================================= + {% if data.use_cron -%} +# Backup the cron configuration ynh_backup --src_path="/etc/cron.d/$app" {% endif %} +{% if data.generator_mode == 'tutorial' -%} +### For apps with huge logs, you might want to pass --is_big, +### and in restore script, mkdir and pass --not_mandatory to ynh_restore_file. +{% endif %} +ynh_backup --src_path="/var/log/$app/" # TODO : add an option to specify log file + {% if data.database != 'false' -%} #================================================= # BACKUP THE DATABASE diff --git a/tools/app_generator/templates/restore.j2 b/tools/app_generator/templates/restore.j2 index 56e4772fe7..d3b16dd276 100644 --- a/tools/app_generator/templates/restore.j2 +++ b/tools/app_generator/templates/restore.j2 @@ -91,11 +91,25 @@ ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf" ynh_systemd_action --action=restart --service_name=fail2ban {% endif %} -# Other various files... +#================================================= +# RESTORE VARIOUS FILES +#================================================= + {% if data.use_cron -%} ynh_restore_file --origin_path="/etc/cron.d/$app" {% endif %} +{% if data.generator_mode == 'tutorial' -%} +### For apps with huge logs, you might want to not backup logs every time: +### The mkdir call is just here in case the log directory was not backed up. +### mkdir -p "/var/log/$app" +### chown $app:www-data "/var/log/$app" +### ynh_restore_file --src_path="/var/log/$app/" --not_mandatory +### +### For other apps, the simple way is better: +{% endif %} +ynh_restore_file --origin_path="/var/log/$app/" # TODO : add custom log file option + #================================================= # RELOAD NGINX AND PHP-FPM OR THE APP SERVICE #=================================================