diff --git a/README-FR.md b/README-FR.md index 472fb7513d6b7b7a6f7c0d6923f33f68df0aba18..c4f0572b6d26fa39e70711860049e3cb4c5c6b8a 100644 --- a/README-FR.md +++ b/README-FR.md @@ -142,14 +142,14 @@ ynh_apps_backup: scheduled_weekday: "*" scheduled_month: "*" src_script: "templates/ynh_apps_backup.sh.j2" - dest_script: "/data/backup/backup_ynh_apps.sh" + dest_script: "/usr/bin" ``` La tâche backup va permettre de sauvegarder les applications Yunohost ainsi que leurs données grâce à la mise en place d'une tâche cron. -- `ynh_apps_backup.scheduled` : Pour activer la fonctionnalité de sauvegarde des applications Yunohost, mettez la valeur à `true`. -- `ynh_apps_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_apps_backup.scheduled_hour/minute/weekday/month`: Permet de modifier quand la tâche cron se déclenche. 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/. -- `src_script` est obligatoire. Il s'agit du répertoire où le fichier de template se situe sur la machine qui exécute Ansible. -- `dest_script` est obligatoire. Il s'agit du répertoire où le fichier de template va être stocké. +- `ynh_apps_backup.scheduled` : active la fonctionnalité de sauvegarde des applications Yunohost, mettez la valeur à `True`. +- `ynh_apps_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_apps_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/. +- `src_script`: il s'agit du chemin absolu où le fichier de template se situe sur la machine qui exécute Ansible. Par défaut, il sera stocké dans `templates/ynh_apps_backup.sh.j2`. +- `dest_script`: il s'agit du répertoire où le fichier de template va être stocké. Par défaut, il sera stocké dans `/usr/local/bin/`. Le script s'appelle `ynh_apps_backup.sh`. ## Dépendances diff --git a/README.md b/README.md index 0c800721c40555642faa8520ca986ef81a98c03a..ffbd4cccd0615072010ec6c3539e36b6bf34bc1f 100644 --- a/README.md +++ b/README.md @@ -142,15 +142,15 @@ ynh_apps_backup: scheduled_weekday: "*" scheduled_month: "*" src_script: "templates/ynh_apps_backup.sh.j2" - dest_script: "/data/backup/backup_ynh_apps.sh" + dest_script: "/usr/bin" ``` The backup task will allow to backup Yunohost applications and their data by setting up a cron job. -- `ynh_apps_backup.scheduled`: To enable the Yunohost applications backup feature, set the value to `true`. -- `ynh_apps_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_apps_backup.scheduled_hour/minute/weekday/month`: Allows you to change when the cron job is triggered. 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/. -- `src_script` is mandatory. This is the directory where the template file is located on the machine running Ansible. -- `dest_script` is required. This is the directory where the template file will be stored. +- `ynh_apps_backup.scheduled`: to enable the Yunohost applications backup feature, set the value to `True`. +- `ynh_apps_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_apps_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/. +- `src_script`: this is the absolute path where the template file is located on the machine running Ansible. By default is will be stored in `templates/ynh_apps_backup.sh.j2`. +- `dest_script`: this is the directory where the template file will be stored. By default is will be stored in `/usr/local/bin`. The script is named `ynh_apps_backup.sh`. ## Dependencies diff --git a/defaults/main.yml b/defaults/main.yml index d773c28f9a6ee366f85b183efd5b760320649ee7..a1dfea75adf2279056e5455f8d2e27581a87d1f5 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -65,11 +65,11 @@ ynh_apps: null # Variables for apps backup ynh_apps_backup: - scheduled: "false" + scheduled: False # directory: "/data/backup" # scheduled_hour: 3 # scheduled_minute: "0" # scheduled_weekday: "*" # scheduled_month: "*" # src_script: "templates/ynh_apps_backup.sh.j2" - # dest_script: "/data/backup/backup_ynh_apps.sh" + # dest_script: "/usr/local/bin/" diff --git a/tasks/backup.yml b/tasks/backup.yml index c454fc2540af75d4aca1d6ed9a24b2e1d53f9889..183b512ad5274b040df1bfb78f4c2cfa96d646b8 100644 --- a/tasks/backup.yml +++ b/tasks/backup.yml @@ -20,18 +20,18 @@ - name: Create backup folder ansible.builtin.file: - path: "{{ ynh_apps_backup.directory | default('/home/yunohost.backup/') }}" + path: "{{ ynh_apps_backup.directory | default('/home/yunohost.backup/archives') }}" state: directory mode: '0750' - + tags: test - name: Create apps backup script ansible.builtin.template: - src: "{{ ynh_apps_backup.src_script }}" - dest: "{{ ynh_apps_backup.dest_script }}" + src: "{{ ynh_apps_backup.src_script | default('templates/ynh_apps_backup.sh.j2') }}" + dest: "{{ ynh_apps_backup.dest_script | default('/usr/local/bin/') }}ynh_apps_backup.sh" owner: root group: root mode: '0740' - + tags: test - name: Create cron task to perform YNH apps backup ansible.builtin.cron: name: "auto-backup apps to {{ ynh_apps_backup.directory | default('/home/yunohost.backup/archives') }}" @@ -40,5 +40,6 @@ hour: "{{ ynh_apps_backup.scheduled_hour | default('1') }}" minute: "{{ ynh_apps_backup.scheduled_minute | default('0') }}" user: root - job: "{{ ynh_apps_backup.dest_script }}" + job: "{{ ynh_apps_backup.dest_script | default('/usr/local/bin/') }}ynh_apps_backup.sh" cron_file: ynh_apps_backup_cron + tags: test diff --git a/tasks/main.yml b/tasks/main.yml index dbb15f6321e7a1a6fdf5470257d3d98fbe7b6533..1782880515fc6dd9fa910464a338cf057867a614 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -75,4 +75,5 @@ - name: Enable Yunohost apps backup ansible.builtin.include_tasks: backup.yml - when: ynh_apps_backup.scheduled == "true" + when: ynh_apps_backup.scheduled + tags: test diff --git a/templates/ynh_apps_backup.sh.j2 b/templates/ynh_apps_backup.sh.j2 index e973978678fbed161781845a64789980a1ad2f01..e31df1a7e57f9c99abfd6cb5e794a282d06c6bd1 100644 --- a/templates/ynh_apps_backup.sh.j2 +++ b/templates/ynh_apps_backup.sh.j2 @@ -1,7 +1,7 @@ #!/bin/sh {% if ynh_apps_backup.directory is string %} -yunohost backup create --apps --output-directory {{ ynh_apps_backup.directory }}/backup_$(date +%Y%m%d_%H%M%S) +yunohost backup create --apps --output-directory {{ ynh_apps_backup.directory }}/backup_$(date +%Y%m%d_%H%M) {% else %} yunohost backup create --apps {% endif %}