From 25d09172a00974446966251ca82ce56f5cfb6c31 Mon Sep 17 00:00:00 2001
From: Arthur BOUDREAULT <arthur@lydra.fr>
Date: Mon, 25 Jul 2022 15:46:49 +0200
Subject: [PATCH] refactor(ynh_backup): add default vars for backup script

---
 roles/ynh_backup/templates/ynh_backup.sh.j2 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/roles/ynh_backup/templates/ynh_backup.sh.j2 b/roles/ynh_backup/templates/ynh_backup.sh.j2
index 8021f9c..e3aa9f5 100644
--- a/roles/ynh_backup/templates/ynh_backup.sh.j2
+++ b/roles/ynh_backup/templates/ynh_backup.sh.j2
@@ -1,7 +1,7 @@
 #!/bin/bash
 today="$(date +%Y%m%d)"
 number_to_keep="{{ number_days_to_keep }}"
-old_backup_list="$(yunohost backup list --output-as plain | head -n -"$number_to_keep")" # Afficher toutes les lignes de sauvegardes à part les deux dernières.
+old_backup_list="$(yunohost backup list --output-as plain | head -n -"$number_to_keep")"
 
 _good() {
     echo "SUCCESS: ${1}" && exit 0
@@ -13,7 +13,7 @@ _fail() {
 
 _create_ynh_backup() {
   echo "Backing up $today YunoHost data now."
-  yunohost backup create {% if ynh_backup.system %}--system{% endif %}{% if ynh_backup.apps %} --apps{% endif %}{% if ynh_backup.directory %} --output-directory {{ ynh_backup.directory }}/backup_"$today" {% endif %} || _fail "can't create a backup"
+  yunohost backup create {% if ynh_backup.system|default(ynh_backup.system == true) %}--system{% endif %}{% if ynh_backup.apps|default(ynh_backup.apps == true) %} --apps{% endif %}{% if ynh_backup.directory|default(ynh_backup.directory == "/data/backup") %} --output-directory {{ ynh_backup.directory }}/backup_"$today" {% endif %} || _fail "can't create a backup"
 
 }
 
-- 
GitLab