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 30ca7624 authored by Arthur BOUDREAULT's avatar Arthur BOUDREAULT
Browse files

refactor: restructuring role into collection #5

parent 1f1fed46
No related branches found
No related tags found
No related merge requests found
Pipeline #3693 passed with warnings
This commit is part of merge request !24. Comments created here will be created in the context of that merge request.
...@@ -25,24 +25,28 @@ Les variables par défaut sont disponibles dans `default/main.yml` cependant il ...@@ -25,24 +25,28 @@ Les variables par défaut sont disponibles dans `default/main.yml` cependant il
### Gestion des sauvegardes ### Gestion des sauvegardes
```yml ```yml
ynh_apps_backup: ynh_backup:
scheduled: "true" scheduled: True
directory: "/data/backup" directory: "/data/backup"
scheduled_hour: "*" scheduled_hour: "*"
scheduled_minute: "*/30" scheduled_minute: "*/30"
scheduled_weekday: "*" scheduled_weekday: "*"
scheduled_month: "*" scheduled_month: "*"
src_script: "templates/ynh_apps_backup.sh.j2" system: True
apps: True
src_script: "templates/ynh_backup.sh.j2"
dest_script: "/usr/bin" 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. 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` : active la fonctionnalité de sauvegarde des applications Yunohost, mettez la valeur à `True`. - `ynh_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_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/>. - `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/>.
- `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`. - `ynh_backup.system` : est obligatoire. Activez la sauvegarde du système Yunohost en mettant la valeur à `True`.
- `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`. - `ynh_backup.apps` : est obligatoire. Activez la sauvegarde des applications Yunohost en mettant la valeur à `True`.
- `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_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_backup.sh`.
## Dépendances ## Dépendances
......
...@@ -25,24 +25,28 @@ Default variables are available in `default/main.yml` however it is necessary to ...@@ -25,24 +25,28 @@ Default variables are available in `default/main.yml` however it is necessary to
### Backups management ### Backups management
```yml ```yml
ynh_apps_backup: ynh_backup:
scheduled: "true" scheduled: True
directory: "/data/backup" directory: "/data/backup"
scheduled_hour: "*" scheduled_hour: "*"
scheduled_minute: "*/30" scheduled_minute: "*/30"
scheduled_weekday: "*" scheduled_weekday: "*"
scheduled_month: "*" scheduled_month: "*"
src_script: "templates/ynh_apps_backup.sh.j2" system: True
apps: True
src_script: "templates/ynh_backup.sh.j2"
dest_script: "/usr/bin" dest_script: "/usr/bin"
``` ```
The backup task will allow to backup Yunohost applications and their data by setting up a cron job. 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_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_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/>. - `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/>.
- `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`. - `ynh_backup.system` : is mandatory. Enables automatic backup of the Yunohost system by setting the value to `True`.
- `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`. - `ynh_backup.apps` : est obligatoire. Enables automatic backup of Yunohost applications by setting the value to `True`.
- `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_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_backup.sh`.
## Dependencies ## Dependencies
......
...@@ -19,12 +19,14 @@ ...@@ -19,12 +19,14 @@
#-----------------------------------------------------------------------------# #-----------------------------------------------------------------------------#
# Variables for apps backup # Variables for apps backup
ynh_apps_backup: ynh_backup:
scheduled: False scheduled: False
# directory: "/data/backup" # directory: "/data/backup"
# scheduled_hour: 3 # scheduled_hour: 3
# scheduled_minute: "0" # scheduled_minute: "0"
# scheduled_weekday: "*" # scheduled_weekday: "*"
# scheduled_month: "*" # scheduled_month: "*"
# src_script: "templates/ynh_apps_backup.sh.j2" # system: True
# apps: True
# src_script: "templates/ynh_backup.sh.j2"
# dest_script: "/usr/local/bin/" # dest_script: "/usr/local/bin/"
...@@ -20,26 +20,25 @@ ...@@ -20,26 +20,25 @@
- name: Create backup folder - name: Create backup folder
ansible.builtin.file: ansible.builtin.file:
path: "{{ ynh_apps_backup.directory | default('/home/yunohost.backup/archives') }}" path: "{{ ynh_backup.directory | default('/home/yunohost.backup/archives') }}"
state: directory state: directory
mode: '0750' mode: '0750'
tags: test
- name: Create apps backup script - name: Create backup script
ansible.builtin.template: ansible.builtin.template:
src: "{{ ynh_apps_backup.src_script | default('templates/ynh_apps_backup.sh.j2') }}" src: "{{ ynh_backup.src_script | default('templates/ynh_backup.sh.j2') }}"
dest: "{{ ynh_apps_backup.dest_script | default('/usr/local/bin/') }}ynh_apps_backup.sh" dest: "{{ ynh_backup.dest_script | default('/usr/local/bin/') }}ynh_backup.sh"
owner: root owner: root
group: root group: root
mode: '0740' mode: '0740'
tags: test
- name: Create cron task to perform YNH apps backup - name: Create cron task to perform YNH backup
ansible.builtin.cron: ansible.builtin.cron:
name: "auto-backup apps to {{ ynh_apps_backup.directory | default('/home/yunohost.backup/archives') }}" name: "auto-backup to {{ ynh_backup.directory | default('/home/yunohost.backup/archives') }}"
month: "{{ ynh_apps_backup.scheduled_month | default('*') }}" month: "{{ ynh_backup.scheduled_month | default('*') }}"
weekday: "{{ ynh_apps_backup.scheduled_weekday | default('*') }}" weekday: "{{ ynh_backup.scheduled_weekday | default('*') }}"
hour: "{{ ynh_apps_backup.scheduled_hour | default('1') }}" hour: "{{ ynh_backup.scheduled_hour | default('1') }}"
minute: "{{ ynh_apps_backup.scheduled_minute | default('0') }}" minute: "{{ ynh_backup.scheduled_minute | default('0') }}"
user: root user: root
job: "{{ ynh_apps_backup.dest_script | default('/usr/local/bin/') }}ynh_apps_backup.sh" job: "{{ ynh_backup.dest_script | default('/usr/local/bin/') }}ynh_backup.sh"
cron_file: ynh_apps_backup_cron cron_file: ynh_backup_cron
tags: test
#!/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)
{% else %}
yunohost backup create --apps
{% endif %}
#!/bin/sh
{% if ynh_backup.system and ynh_backup.apps and ynh_backup.directory %}
yunohost backup create --output-directory {{ ynh_backup.directory }}/backup_$(date +%Y%m%d_%H%M)
{% elif ynh_backup.system and ynh_backup.apps %}
yunohost backup create
{% elif ynh_backup.system %}
yunohost backup create --system
{% elif ynh_backup.apps %}
yunohost backup create --apps
{% endif %}
{% if ynh_backup.system is false and ynh_backup.apps is false %}
echo "Read the readme to know more about ynh_backup.system and ynh_backup.apps"
echo "TO BE DEFINED"
exit 1
...@@ -52,8 +52,8 @@ A cron job can been set up to automate the check for system and application upda ...@@ -52,8 +52,8 @@ A cron job can been set up to automate the check for system and application upda
- `ynh_autoupdate.scheduled` : enables the cron job by setting the value to `True`. - `ynh_autoupdate.scheduled` : enables the cron job by setting the value to `True`.
- `ynh_autoupdate.special_time`: it is mandatory. It allows you to specify when you want this task to be executed. Possible values: (`annually`,`daily`,`hourly`,`monthly`,`reboot`,`weekly`,`yearly`). To learn more about special times, click [here](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/cron_module.html). - `ynh_autoupdate.special_time`: it is mandatory. It allows you to specify when you want this task to be executed. Possible values: (`annually`,`daily`,`hourly`,`monthly`,`reboot`,`weekly`,`yearly`). To learn more about special times, click [here](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/cron_module.html).
- `ynh_autoupdate.apps`: is mandatory. Enable automatic updating of Yunohost applications by setting the value to `True`. - `ynh_autoupdate.apps`: is mandatory. Enables automatic updating of Yunohost applications by setting the value to `True`.
- `ynh_autoupdate.system`: is mandatory. Enable automatic updating of the Yunohost system by setting the value to `True`. - `ynh_autoupdate.system`: is mandatory. Enables automatic updating of the Yunohost system by setting the value to `True`.
- `ynh_autoupdate.dest_script`: it is the path to the directory where the update script will be installed on the server. The default value is `/usr/local/bin`. The script is named `ynh_autoupdate.sh`. - `ynh_autoupdate.dest_script`: it is the path to the directory where the update script will be installed on the server. The default value is `/usr/local/bin`. The script is named `ynh_autoupdate.sh`.
If available, updates are done automatically. In case of problems following an application update, you can read logs located in `/var/log/yunohost/categories/operation` . You also have the possibility to rollback to the previous version since Yunohost always makes an automatic backup of an application when it is updated. If available, updates are done automatically. In case of problems following an application update, you can read logs located in `/var/log/yunohost/categories/operation` . You also have the possibility to rollback to the previous version since Yunohost always makes an automatic backup of an application when it is updated.
......
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