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

refactor(ynh_backup): add default vars for local backups

parent 2ec9d974
No related branches found
No related tags found
1 merge request!39Resolve "refactor: improve backup usage README"
Pipeline #7467 passed with warnings
......@@ -39,7 +39,7 @@ ynh_backup:
- `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.
- `ynh_backup.number_days_to_keep` : Détermine le nombre de jours à garder pour le système de purge, la valeur par défaut est 2.
- ⚠️ 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
......
......@@ -39,7 +39,7 @@ ynh_backup:
- `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.
- `ynh_backup.number_days_to_keep` : Determines the number of days to keep for the purging system, the default is 2.
- ⚠️ 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
......
......@@ -21,15 +21,6 @@
# 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
number_days_to_keep: "2"
# Variables for YunoHost BorgBackup
ynh_borg_backup_scheduled: False
......
......@@ -25,9 +25,10 @@
- name: Create backup folder if doesn't already exist
ansible.builtin.file:
path: "{{ ynh_backup.directory | default('/home/yunohost.backup/archives') }}"
path: "{{ ynh_backup.directory }}"
state: directory
mode: '0750'
when: ynh_backup.directory is defined
tags: backup
- name: Create backup script
......@@ -41,7 +42,7 @@
- name: Create cron task to schedule YNH backup script
ansible.builtin.cron:
name: "auto-backup to {{ ynh_backup.directory | default('/home/yunohost.backup/archives') }}"
name: "auto-backup to {{ ynh_backup.directory | default(_ynh_backup_directory) }}"
month: "{{ ynh_backup.scheduled_month | default('*') }}"
weekday: "{{ ynh_backup.scheduled_weekday | default('*') }}"
hour: "{{ ynh_backup.scheduled_hour | default('1') }}"
......
......@@ -13,7 +13,7 @@ _fail() {
_create_ynh_backup() {
echo "Backing up $today YunoHost data now."
yunohost backup create {% if ynh_backup.system | default(True) %}--system{% endif %}{% if ynh_backup.apps | default(True) %} --apps{% endif %}{% if ynh_backup.directory | default("/data/backup") %} --output-directory {{ ynh_backup.directory }}/backup_"$today" {% endif %} || _fail "can't create a backup"
yunohost backup create {% if ynh_backup.system | default(True) %}--system{% endif %}{% if ynh_backup.apps | default(True) %} --apps{% endif %}{% if ynh_backup.directory is defined %} --output-directory {{ ynh_backup.directory }}/backup_"$today" {% endif %} || _fail "can't create a backup"
}
......
......@@ -21,3 +21,4 @@
# Variables for backup
ynh_backup_src_script: "templates/ynh_backup.sh.j2"
ynh_backup_dest_script: "/usr/local/bin/ynh_backup.sh"
_ynh_backup_directory: "/home/yunohost.backup/archives"
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