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

--wip-- [skip ci]

parent 41a1d1d0
No related branches found
No related tags found
1 merge request!19Draft: Resolve "backup all installed apps and system"
Pipeline #3624 skipped
...@@ -142,14 +142,14 @@ ynh_apps_backup: ...@@ -142,14 +142,14 @@ ynh_apps_backup:
scheduled_weekday: "*" scheduled_weekday: "*"
scheduled_month: "*" scheduled_month: "*"
src_script: "templates/ynh_apps_backup.sh.j2" 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. 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.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.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/. - `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` est obligatoire. Il s'agit du répertoire où le fichier de template se situe sur la machine qui exécute Ansible. - `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` est obligatoire. Il s'agit du répertoire où le fichier de template va être stocké. - `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 ## Dépendances
......
...@@ -142,15 +142,15 @@ ynh_apps_backup: ...@@ -142,15 +142,15 @@ ynh_apps_backup:
scheduled_weekday: "*" scheduled_weekday: "*"
scheduled_month: "*" scheduled_month: "*"
src_script: "templates/ynh_apps_backup.sh.j2" 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. 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.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.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/. - `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` is mandatory. This is the directory where the template file is located on the machine running Ansible. - `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` is required. This is the directory where the template file will be stored. - `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 ## Dependencies
......
...@@ -65,11 +65,11 @@ ynh_apps: null ...@@ -65,11 +65,11 @@ ynh_apps: null
# Variables for apps backup # Variables for apps backup
ynh_apps_backup: ynh_apps_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" # src_script: "templates/ynh_apps_backup.sh.j2"
# dest_script: "/data/backup/backup_ynh_apps.sh" # dest_script: "/usr/local/bin/"
...@@ -20,18 +20,18 @@ ...@@ -20,18 +20,18 @@
- name: Create backup folder - name: Create backup folder
ansible.builtin.file: ansible.builtin.file:
path: "{{ ynh_apps_backup.directory | default('/home/yunohost.backup/') }}" path: "{{ ynh_apps_backup.directory | default('/home/yunohost.backup/archives') }}"
state: directory state: directory
mode: '0750' mode: '0750'
tags: test
- name: Create apps backup script - name: Create apps backup script
ansible.builtin.template: ansible.builtin.template:
src: "{{ ynh_apps_backup.src_script }}" src: "{{ ynh_apps_backup.src_script | default('templates/ynh_apps_backup.sh.j2') }}"
dest: "{{ ynh_apps_backup.dest_script }}" dest: "{{ ynh_apps_backup.dest_script | default('/usr/local/bin/') }}ynh_apps_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 apps backup
ansible.builtin.cron: ansible.builtin.cron:
name: "auto-backup apps to {{ ynh_apps_backup.directory | default('/home/yunohost.backup/archives') }}" name: "auto-backup apps to {{ ynh_apps_backup.directory | default('/home/yunohost.backup/archives') }}"
...@@ -40,5 +40,6 @@ ...@@ -40,5 +40,6 @@
hour: "{{ ynh_apps_backup.scheduled_hour | default('1') }}" hour: "{{ ynh_apps_backup.scheduled_hour | default('1') }}"
minute: "{{ ynh_apps_backup.scheduled_minute | default('0') }}" minute: "{{ ynh_apps_backup.scheduled_minute | default('0') }}"
user: root 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 cron_file: ynh_apps_backup_cron
tags: test
...@@ -75,4 +75,5 @@ ...@@ -75,4 +75,5 @@
- name: Enable Yunohost apps backup - name: Enable Yunohost apps backup
ansible.builtin.include_tasks: backup.yml ansible.builtin.include_tasks: backup.yml
when: ynh_apps_backup.scheduled == "true" when: ynh_apps_backup.scheduled
tags: test
#!/bin/sh #!/bin/sh
{% if ynh_apps_backup.directory is string %} {% 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 %} {% else %}
yunohost backup create --apps yunohost backup create --apps
{% endif %} {% endif %}
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