Pour tout problème contactez-nous par mail : support@froggit.fr | La FAQ :grey_question: | Rejoignez-nous sur le Chat :speech_balloon:

Skip to content
Snippets Groups Projects
Commit 06d9a65a authored by Arthur BOUDREAULT's avatar Arthur BOUDREAULT
Browse files

refactor: feature is now stable + add explaination in readmes

parent 1b9b1e13
No related branches found
No related tags found
1 merge request!19Draft: Resolve "backup all installed apps and system"
Pipeline #3325 passed with warnings
......@@ -131,6 +131,29 @@ Cette tâche utilisant le module template, vous pouvez tout à fait utiliser vos
Pour `owner` et `group`, par défaut le fichier va prendre comme utilisateur propriétaire le nom de l'application et comme groupe propriétaire www-data (groupe NGINX). Vous pouvez les changer en précisant des valeurs différentes.
### Gestion des sauvegardes
```yml
- 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') }}"
month: "{{ ynh_apps_backup.scheduled_month | default('*') }}"
weekday: "{{ ynh_apps_backup.scheduled_weekday | default('*') }}"
hour: "{{ ynh_apps_backup.scheduled_hour | default('1') }}"
minute: "{{ ynh_apps_backup.scheduled_minute | default('0') }}"
user: root
job: "{% if ynh_apps_backup.directory is string %}
yunohost backup create --apps --output-directory {{ ynh_apps_backup.directory }}_$(date +%Y%m%d_%H%M%S)
{% else %}
yunohost backup create --apps
{% endif %}"
cron_file: ynh_apps_backup_cron
```
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/.
## Dépendances
Aucune.
......
......@@ -131,6 +131,30 @@ Because this task uses the template module, you can use your own variables and c
For `owner` and `group`, by default the file will take as owner the name of the application and as owner www-data(NGINX group). You can change them by specifying different values.
### Backups management
```yml
- 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') }}"
month: "{{ ynh_apps_backup.scheduled_month | default('*') }}"
weekday: "{{ ynh_apps_backup.scheduled_weekday | default('*') }}"
hour: "{{ ynh_apps_backup.scheduled_hour | default('1') }}"
minute: "{{ ynh_apps_backup.scheduled_minute | default('0') }}"
user: root
job: "{% if ynh_apps_backup.directory is string %}
yunohost backup create --apps --output-directory {{ ynh_apps_backup.directory }}_$(date +%Y%m%d_%H%M%S)
{% else %}
yunohost backup create --apps
{% endif %}"
cron_file: ynh_apps_backup_cron
```
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/.
## Dependencies
None.
......
......@@ -64,10 +64,10 @@ ynh_apps: null
# group: ttrss # Only provide if different from www-data
# Variables for backup
# ynh_backup:
# directory: "/data/backup" #If you want default folder, just leave it empty
# scheduled: "true"
# scheduled_hour: 3
# scheduled_minute: "0"
# scheduled_weekday: "*"
# scheduled_month: "*"
ynh_apps_backup:
scheduled: "false"
# directory: "/data/backup"
# scheduled_hour: 3
# scheduled_minute: "0"
# scheduled_weekday: "*"
# scheduled_month: "*"
......@@ -20,21 +20,15 @@
- name: Create cron task to perform YNH apps backup
ansible.builtin.cron:
name: "auto-backup apps to {{ ynh_backup.directory | default('/home/yunohost.backup/archives') }}"
month: "{{ ynh_backup.scheduled_month | default('*') }}"
weekday: "{{ ynh_backup.scheduled_weekday | default('*') }}"
hour: "{{ ynh_backup.scheduled_hour | default('1') }}"
minute: "{{ ynh_backup.scheduled_minute | default('0') }}"
name: "auto-backup apps to {{ ynh_apps_backup.directory | default('/home/yunohost.backup/archives') }}"
month: "{{ ynh_apps_backup.scheduled_month | default('*') }}"
weekday: "{{ ynh_apps_backup.scheduled_weekday | default('*') }}"
hour: "{{ ynh_apps_backup.scheduled_hour | default('1') }}"
minute: "{{ ynh_apps_backup.scheduled_minute | default('0') }}"
user: root
job: "yunohost backup create --apps
{% if ynh_backup.directory is string %}
-o {{ ynh_backup.directory }} -n {{ ynh_backup.name }}
job: "{% if ynh_apps_backup.directory is string %}
yunohost backup create --apps --output-directory {{ ynh_apps_backup.directory }}_$(date +%Y%m%d_%H%M%S)
{% else %}
-n {{ ynh_backup.name }}
yunohost backup create --apps
{% endif %}"
cron_file: cron_task_ynh_apps_backup
- name: restart cron config ##Is it useful to restart cron after config change?
ansible.builtin.service:
name: cron
state: restart
cron_file: ynh_apps_backup_cron
......@@ -73,6 +73,6 @@
ansible.builtin.include_tasks: apps.yml
when: ynh_apps
- name: Enable Yunohost backup
- name: Enable Yunohost apps backup
ansible.builtin.include_tasks: backup.yml
when: ynh_backup.scheduled == 'true'
when: ynh_apps_backup.scheduled == "true"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment