generated from ansible/ansible_template
72 lines
1.8 KiB
YAML
72 lines
1.8 KiB
YAML
- name: "Try to update restic"
|
|
command: "restic self-update"
|
|
register: restic_update
|
|
ignore_errors: true
|
|
|
|
- name: "Download restic"
|
|
get_url:
|
|
url: "{{ restic_url }}"
|
|
dest: /tmp/restic.bz2
|
|
register: restic_download
|
|
when: restic_update is failed
|
|
|
|
- name: "Extract restic"
|
|
command: "bzip2 -df /tmp/restic.bz2"
|
|
register: restic_extract
|
|
when: restic_download is changed
|
|
|
|
- name: "Install restic"
|
|
copy:
|
|
src: "/tmp/restic"
|
|
dest: "/usr/bin/restic"
|
|
remote_src: yes
|
|
mode: "751"
|
|
when: restic_extract is changed
|
|
|
|
- name: "Copy the docker backup script"
|
|
blockinfile:
|
|
path: "/home/ansible/backup-to-restic"
|
|
mode: 0755
|
|
owner: "ansible"
|
|
group: "ansible"
|
|
create: yes
|
|
block: |
|
|
#!/bin/bash
|
|
export RESTIC_REPOSITORY=sftp:borg@10.7.89.117:restic
|
|
export RESTIC_PASSWORD={{ restic_password }}
|
|
|
|
cd {{ docker_project_path }}
|
|
sudo docker-compose pause
|
|
sudo -E restic backup /home/ansible --exclude-file=/etc/restic/excludes.txt
|
|
sudo docker-compose unpause
|
|
when:
|
|
- "'docker' in group_names"
|
|
- docker_project_name
|
|
|
|
- name: "Copy the backup script"
|
|
blockinfile:
|
|
path: "/home/andreas/backup-to-restic"
|
|
mode: 0755
|
|
owner: "andreas"
|
|
group: "andreas"
|
|
create: yes
|
|
block: |
|
|
#!/bin/bash
|
|
export RESTIC_REPOSITORY=sftp:borg@10.7.89.117:restic
|
|
export RESTIC_PASSWORD={{ restic_password }}
|
|
|
|
restic backup /home/andreas --exclude-file=/etc/restic/excludes.txt
|
|
when: (docker_project_name is undefined and "'docker' in group_names") or
|
|
("'docker' not in group_names")
|
|
|
|
- name: "Create the restic config dir"
|
|
file:
|
|
path: "/etc/restic/"
|
|
state: directory
|
|
mode: "0755"
|
|
|
|
- name: "Copy excludes file"
|
|
copy:
|
|
src: "excludes.txt"
|
|
dest: "/etc/restic/excludes.txt"
|