Skip to content

Commit

Permalink
v0.8.5 : add log file + various stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
lapineige authored Mar 6, 2024
1 parent fc149d5 commit 2de77db
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 6 deletions.
31 changes: 26 additions & 5 deletions tools/app_generator/templates/backup.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 15 additions & 1 deletion tools/app_generator/templates/restore.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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
#=================================================
Expand Down

0 comments on commit 2de77db

Please sign in to comment.