diff --git a/roles/ynh_backup/defaults/main.yml b/roles/ynh_backup/defaults/main.yml index 9b4d8ba9bf653fb27628aa4beddc9737aef12389..4d534db05b43e238654a8a9b4ce3f00cc353907f 100644 --- a/roles/ynh_backup/defaults/main.yml +++ b/roles/ynh_backup/defaults/main.yml @@ -29,14 +29,16 @@ ynh_backup: # system: True # apps: True -ynh_borg_backup: - scheduled: False - # borg_source_directories: "{{ borg_ynh_src_dir }}" - # borg_repository: "{{ borg_ynh_remote_repo }}" - # borgmatic_config_name: "{{ borgmatic_conf_name }}" - # borg_encryption_passphrase: "{{ borg_remote_repo_encryption_passphrase }}" - # borg_retention_policy: - # keep_daily: "{{ borg_days_to_keep }}" - # keep_weekly: "{{ borg_weeks_to_keep }}" - # keep_monthly: "{{ borg_months_to_keep }}" - # borgmatic_cron_name: "{{ borgmatic_ynh_cron_name }}" +ynh_borg_backup_scheduled: False +ynh_borg_backup_remote_repo: False +# borg_source_directories: +# - "/data/yunohost/backup" +# borg_repository: "/data/backup/live" +# borg_init_command: "borgmatic init -c /etc/borgmatic/{{ borgmatic_config_name }} -e repokey --syslog-verbosity 1" +# borgmatic_config_name: "borgmatic_ynh_config" +# borg_encryption_passphrase: "PLEASECHANGEME" +# borg_retention_policy: +# keep_daily: "4" +# keep_weekly: "0" +# keep_monthly: "0" +# borgmatic_cron_name: "borgmatic_ynh_cron" diff --git a/roles/ynh_backup/tasks/borg.yml b/roles/ynh_backup/tasks/borg.yml index cca0b7d19aececf0a33b6564b053ea81573f21e8..15345866cd363598cc0c3eba9a43eb8bddde5a0c 100644 --- a/roles/ynh_backup/tasks/borg.yml +++ b/roles/ynh_backup/tasks/borg.yml @@ -18,13 +18,16 @@ # # #-----------------------------------------------------------------------------# - name: Download BorgBackup role on localhost - local_action: ansible.builtin.command ansible-galaxy install -r requirements.yml + local_action: + module: ansible.builtin.command + cmd: ansible-galaxy install -r requirements.yml ##Will install role in default location (~/.ansible) + become: False #Become True on playbook but False here otherwise needs a password need to be provided - name: import BorgBackup role ansible.builtin.import_role: name: m3nu.ansible_role_borgbackup -- name: Configure host for Borg Remote repository +- name: Configure host for Borg Remote repository #in README, need to tell that ssh pub/priv keys are necessary block: - name: deploy ssh public key for BorgBackup ansible.builtin.copy: @@ -48,24 +51,14 @@ regexp: "# ssh_command: ssh -i ~/.ssh/id_ed25519" line: " ssh_command: ssh -p 7410 -o StrictHostKeychecking=no -i {{ borg_ssh_keys_dest }}" state: present + when: ynh_borg_backup_remote_repo - - name: change archive name in "/etc/borgmatic/{{ borgmatic_config_name }}" - ansible.builtin.lineinfile: - path: "/etc/borgmatic/{{ borgmatic_config_name }}" - regexp: "archive_name_format:" - line: " archive_name_format: {{ borg_archive_name_format }}" - state: present - - - name: Create borg command in /usr/local/bin - ansible.builtin.copy: - content: | - #!/bin/bash - . /opt/borgmatic/bin/activate - borg "$@" - dest: /usr/local/bin/borg - owner: root - group: root - mode: "0755" +- name: change archive name in "/etc/borgmatic/{{ borgmatic_config_name }}" + ansible.builtin.lineinfile: + path: "/etc/borgmatic/{{ borgmatic_config_name }}" + regexp: "archive_name_format:" + line: " archive_name_format: {{ borg_archive_name_format }}" + state: present - - name: Initialize a new Borg remote repository - ansible.builtin.command: "{{ borg_init_command }}" +- name: Initialize a new Borg remote repository + ansible.builtin.command: "{{ borg_init_command }}" diff --git a/roles/ynh_backup/tasks/main.yml b/roles/ynh_backup/tasks/main.yml index f6c157bb9527fff760fffb926f5f93a2dd980a3e..0ce0393990791cd3ac1f76fbde3ae3dc7913bf4e 100644 --- a/roles/ynh_backup/tasks/main.yml +++ b/roles/ynh_backup/tasks/main.yml @@ -26,7 +26,7 @@ - name: Use Borg Backup with YunoHost ansible.builtin.include_tasks: borg.yml - when: ynh_borg_backup.scheduled + when: ynh_borg_backup_scheduled tags: - backup - borg