This repository has been archived on 2021-11-15. You can view files and clone it, but cannot push or open issues or pull requests.
restic/tasks/main.yml

71 lines
1.7 KiB
YAML
Raw Permalink Normal View History

2021-08-24 21:52:28 +02:00
- name: "Try to update restic"
command: "restic self-update"
register: restic_update
ignore_errors: true
2021-08-23 14:54:10 +02:00
- name: "Download restic"
2021-08-23 14:34:24 +02:00
get_url:
url: "{{ restic_url }}"
dest: /tmp/restic.bz2
2021-08-24 21:52:28 +02:00
register: restic_download
when: restic_update is failed
2021-08-23 14:34:24 +02:00
2021-08-23 14:53:08 +02:00
- name: "Extract restic"
2021-08-23 15:07:58 +02:00
command: "bzip2 -df /tmp/restic.bz2"
2021-08-24 21:52:28 +02:00
register: restic_extract
when: restic_download is changed
2021-08-23 14:53:08 +02:00
- name: "Install restic"
copy:
2021-08-23 15:04:53 +02:00
src: "/tmp/restic"
2021-08-23 15:05:47 +02:00
dest: "/usr/bin/restic"
2021-08-23 14:29:27 +02:00
remote_src: yes
mode: "751"
2021-08-24 21:52:28 +02:00
when: restic_extract is changed
2021-08-23 15:19:18 +02:00
2021-11-15 18:27:44 +01:00
- name: "Copy the docker backup script"
2021-11-15 18:20:21 +01:00
blockinfile:
path: "/home/ansible/backup-to-restic"
mode: 0755
2021-11-15 16:52:27 +01:00
owner: "ansible"
group: "ansible"
2021-11-15 18:35:59 +01:00
create: yes
2021-11-15 18:20:21 +01:00
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
2021-11-15 18:31:51 +01:00
when:
- "'docker' in group_names"
2021-11-15 19:20:37 +01:00
- docker_project_name is defined
2021-11-15 18:20:21 +01:00
- name: "Copy the backup script"
blockinfile:
path: "/home/andreas/backup-to-restic"
2021-11-15 16:52:27 +01:00
mode: 0755
2021-11-15 18:20:21 +01:00
owner: "andreas"
group: "andreas"
2021-11-15 18:35:59 +01:00
create: yes
2021-11-15 18:20:21 +01:00
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
2021-11-15 19:20:37 +01:00
when: docker_project_name is undefined
2021-11-15 16:52:27 +01:00
2021-08-23 15:23:39 +02:00
- name: "Create the restic config dir"
file:
path: "/etc/restic/"
state: directory
mode: "0755"
2021-08-23 15:19:18 +02:00
- name: "Copy excludes file"
copy:
src: "excludes.txt"
dest: "/etc/restic/excludes.txt"