diff --git a/roles/ynh_backup/README-FR.md b/roles/ynh_backup/README-FR.md index e36ffae1bb77dc8653fcb75e544571bb4cce11b2..e3715d1857895b589079b0e390776456b18e2704 100644 --- a/roles/ynh_backup/README-FR.md +++ b/roles/ynh_backup/README-FR.md @@ -36,12 +36,13 @@ ynh_backup: number_days_to_keep: "2" ``` -- `ynh_backup.scheduled` : active la fonctionnalité de sauvegarde des applications YunoHost, mettez la valeur à `True`. -- `ynh_backup.directory` : le dossier de sauvegarde par défaut est `/home/yunohost.backup/archives` cependant vous pouvez tout à fait choisir de sauvegarder les backups dans un autre dossier grâce à cette variable. Dans ce cas, de manière à pouvoir restaurer les backups depuis l'interface web, YunoHost créé automatiquement un lien symbolique de l'archive créée vers son dossier par défaut. -- `ynh_backup.scheduled_[hour|minute|weekday|month]`: modifie la planification de la tâche cron. Par défaut, elle se déclenchera tous les jours de l'année à 1 heure du matin. Pour plus d'informations concernant les réglages horaires cron, cet outil peut être utile : <https://crontab.guru/>. -- `ynh_backup.system` : **obligatoire**. Activez la sauvegarde du système YunoHost en mettant la valeur à `True`. -- `ynh_backup.apps` : **obligatoire**. Activez la sauvegarde des applications YunoHost en mettant la valeur à `True`. -- `number_days_to_keep` : **obligatoire**. Détermine le nombre de jours à garder pour le système de purge. +- `ynh_backup.scheduled` : active la fonctionnalité de sauvegarde des applications YunoHost en mettant la valeur à `True`. +- `ynh_backup.directory` : le dossier de sauvegarde par défaut est `/home/yunohost.backup/archives`. Vous pouvez choisir de sauvegarder les backups dans un autre dossier grâce à cette variable. Dans ce cas, de manière à pouvoir restaurer les backups depuis l'interface web, YunoHost créé automatiquement un lien symbolique de l'archive créée vers son dossier par défaut. +- `ynh_backup.scheduled_[hour|minute|weekday|month]`: modifie la planification de la tâche cron. Par défaut, elle se déclenchera tous les jours de l'année à 3 heure du matin. Pour plus d'informations concernant les réglages horaires cron, cet outil peut être utile : <https://crontab.guru/>. +- `ynh_backup.system` : Désactivez la sauvegarde du système YunoHost en mettant la valeur à `False`, la valeur par défaut est à `True`. +- `ynh_backup.apps` : Désactivez la sauvegarde des applications YunoHost en mettant la valeur à `False`, la valeur par défaut est à `True`. +- `number_days_to_keep` : Détermine le nombre de jours à garder pour le système de purge. +- âš ï¸ Attention, à partir du moment où vous activez la fonctionnalité de sauvegarde locale `ynh_backup.scheduled`, vous ne pouvez pas désactiver les sauvegardes système **et** applications. Si vous mettez `ynh_backup.system` **et** `ynh_backup.apps` à `False`, le rôle tombera en erreur. ### Sauvegardes distantes avec BorgBackup diff --git a/roles/ynh_backup/README.md b/roles/ynh_backup/README.md index 5ce82387f84c5991ab79c115da8693d2038768f7..e65fed6a0e9ea8c5962afe45197981b8b3f35a02 100644 --- a/roles/ynh_backup/README.md +++ b/roles/ynh_backup/README.md @@ -34,12 +34,13 @@ ynh_backup: dest_script: "/usr/bin" ``` -- `ynh_backup.scheduled`: to enable the YunoHost applications backup feature, set the value to `True`. -- `ynh_backup.directory`: the default backup folder is `/home/yunohost.backup/archives` however you can choose to save the backups in another folder with this variable. In this case, in order to be able to restore the backups from the web interface, YunoHost automatically creates a symbolic link from the created archive to its default folder. -- `ynh_backup.scheduled_[hour|minute|weekday|month]`: modifies the scheduling of the cron task. By default, it will run every day of the year at 1am. For more information about cron time settings, this tool can be useful: <https://crontab.guru/>. -- `ynh_backup.system`: **mandatory**. Enables automatic backup of the YunoHost system by setting the value to `True`. -- `ynh_backup.apps`: **mandatory**. Enables automatic backup of YunoHost applications by setting the value to `True`. -- `number_days_to_keep` : **mandatory**. Determines the number of days to keep for the purging system. +- `ynh_backup.scheduled`: Enable the YunoHost applications backup feature by setting the value to `True`. +- `ynh_backup.directory`: the default backup folder is `/home/yunohost.backup/archives`. You can choose to save the backups in another folder with this variable. In this case, in order to be able to restore the backups from the web interface, YunoHost automatically creates a symbolic link from the created archive to its default folder. +- `ynh_backup.scheduled_[hour|minute|weekday|month]`: modifies the scheduling of the cron task. By default, it will run every day of the year at 3am. For more information about cron time settings, this tool can be useful: <https://crontab.guru/>. +- `ynh_backup.system`: Disable YunoHost system backup by setting the value to `False`, the default value is `True`. +- `ynh_backup.apps`: Disable backup of YunoHost applications by setting the value to `False`, the default is `True`. +- `number_days_to_keep` : Determines the number of days to keep for the purging system. +- âš ï¸ Beware, once you enable the local backup feature `ynh_backup.scheduled`, you cannot disable system **and** application backups. If you set `ynh_backup.system` **and** `ynh_backup.apps` to `False`, the role will fail. ### remote backups with YunoHost BorgBackup diff --git a/roles/ynh_backup/defaults/main.yml b/roles/ynh_backup/defaults/main.yml index fa8dd2f7c6ec614a828944a76fa00a82b7a7503b..160406038f1ea1354fb401ca91932d2e2c94a3c4 100644 --- a/roles/ynh_backup/defaults/main.yml +++ b/roles/ynh_backup/defaults/main.yml @@ -21,13 +21,13 @@ # Variables for local YunoHost backups ynh_backup: scheduled: False - # directory: "/data/backup" - # scheduled_hour: 3 - # scheduled_minute: "0" - # scheduled_weekday: "*" - # scheduled_month: "*" - # system: True - # apps: True + directory: "/data/backup" + scheduled_hour: "3" + scheduled_minute: "0" + scheduled_weekday: "*" + scheduled_month: "*" + system: True + apps: True number_days_to_keep: "2" diff --git a/roles/ynh_backup/tasks/backup.yml b/roles/ynh_backup/tasks/backup.yml index 688d36a98cac0fd6e892ed021788cfe341fdee6f..9dbc153c863bab0fb25c523b89f814fe926383e3 100644 --- a/roles/ynh_backup/tasks/backup.yml +++ b/roles/ynh_backup/tasks/backup.yml @@ -17,6 +17,11 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # # # #-----------------------------------------------------------------------------# +- name: Fail if variables are not used correctly + ansible.builtin.fail: + msg: You need to define variable ynh_backup.apps and / or ynh_backup.system to True + when: ynh_backup.apps is false and ynh_backup.system is false + tags: backup - name: Create backup folder if doesn't already exist ansible.builtin.file: