diff --git a/README.md b/README.md index 1cb92c9..a4ac4ca 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Main features: - Provision new remote [BorgBase.com](https://www.borgbase.com) repo for storing backups (optional) -## Example Playbook with root as backup user +## Example Playbook with root as backup user and Cron timer ``` - hosts: webservers @@ -20,7 +20,7 @@ Main features: - role: m3nu.ansible_role_borgbackup borg_encryption_passphrase: CHANGEME borg_repository: m5vz9gp4@m5vz9gp4.repo.borgbase.com:repo - borgmatic_timer: systemd + borgmatic_timer: cron borg_source_directories: - /srv/www - /var/lib/automysqlbackup @@ -40,7 +40,7 @@ Main features: port: 5433 ``` -## Example Playbook with service user +## Example Playbook with service user and Systemd timer `` Attention: `` The following implementation leads to problems. If you already use this role and use the user: "root" or the SSH key id_ed25519! diff --git a/tasks/04_create_links_to_borg_and_borgmatic.yml b/tasks/04_create_links_to_borg_and_borgmatic.yml deleted file mode 100644 index b9cadc4..0000000 --- a/tasks/04_create_links_to_borg_and_borgmatic.yml +++ /dev/null @@ -1,40 +0,0 @@ ---- -- name: Create links to the Borgmatic and Borg binarys - tags: - - install_backup - block: - - name: Create borgmatic command in /usr/local/bin - ansible.builtin.copy: - content: | - #!/bin/bash - . "{{ borg_venv_path }}"/bin/activate - borgmatic "$@" - dest: /usr/local/bin/borgmatic - mode: "0755" - owner: "{{ borgbackup_user }}" - group: "{{ borgbackup_group }}" - - - name: Create borg command in /usr/local/bin - ansible.builtin.copy: - content: | - #!/bin/bash - . "{{ borg_venv_path }}"/bin/activate - borg "$@" - dest: /usr/local/bin/borg - mode: "0755" - owner: "{{ borgbackup_user }}" - group: "{{ borgbackup_group }}" - -- name: Install helper scripts - tags: - - never - - backup_install_helper - ansible.builtin.copy: - src: "{{ item.src }}" - dest: "{{ item.dest }}" - owner: "{{ item.owner }}" - group: "{{ item.group }}" - mode: "{{ item.mode }}" - with_items: - - { src: "docker.sh", dest: "/usr/local/bin/docker.sh", owner: "{{ borgbackup_user }}", group: "{{ borgbackup_group }}", mode: "0770" } -... diff --git a/tasks/04_helper_scripts.yml b/tasks/04_helper_scripts.yml new file mode 100644 index 0000000..918ed9f --- /dev/null +++ b/tasks/04_helper_scripts.yml @@ -0,0 +1,14 @@ +--- +- name: Install helper scripts + tags: + - never + - backup_install_helper + ansible.builtin.copy: + src: "{{ item.src }}" + dest: "{{ item.dest }}" + owner: "{{ item.owner }}" + group: "{{ item.group }}" + mode: "{{ item.mode }}" + with_items: + - { src: "docker.sh", dest: "/usr/local/bin/docker.sh", owner: "{{ borgbackup_user }}", group: "{{ borgbackup_group }}", mode: "0770" } +... diff --git a/tasks/noauto_create_timer_systemd.yml b/tasks/noauto_create_timer_systemd.yml index 20f708a..96f434f 100644 --- a/tasks/noauto_create_timer_systemd.yml +++ b/tasks/noauto_create_timer_systemd.yml @@ -35,7 +35,7 @@ - borgmatic.service # bug: Need own section without masked else the timer are skipped - - name: Set borgmatic timers to stopped - fresh installed + - name: Set borgmatic timers to stopped - fresh installed ansible.builtin.systemd: name: "{{ item }}" state: stopped diff --git a/tasks/noauto_install_pip.yml b/tasks/noauto_install_pip.yml index 687faf2..60f8578 100644 --- a/tasks/noauto_install_pip.yml +++ b/tasks/noauto_install_pip.yml @@ -1,5 +1,5 @@ --- -- name: Install borgbackup by pip +- name: Install Borg and Borgmatic via pip tags: - install_backup block: @@ -30,4 +30,32 @@ virtualenv: "{{ borg_venv_path }}" when: borg_python_packages is defined loop: "{{ borg_python_packages }}" + +- name: Create links to Borgmatic and Borg binarys + tags: + - install_backup + block: + - name: Create borgmatic command in /usr/local/bin + ansible.builtin.copy: + content: | + #!/bin/bash + . "{{ borg_venv_path }}"/bin/activate + borgmatic "$@" + dest: /usr/local/bin/borgmatic + mode: "0755" + owner: "{{ borgbackup_user }}" + group: "{{ borgbackup_group }}" + + - name: Create borg command in /usr/local/bin + ansible.builtin.copy: + content: | + #!/bin/bash + . "{{ borg_venv_path }}"/bin/activate + borg "$@" + dest: /usr/local/bin/borg + mode: "0755" + owner: "{{ borgbackup_user }}" + group: "{{ borgbackup_group }}" + + ...