Partially complete new docker_borg_backup role
This commit is contained in:
1 parent
e535d8a2f6
commit
de0bcc8df4
6 files changed
+49
-12
No files matched your search
@@ -1,2 +1,43 @@
|
||||
---
|
||||
# tasks file for docker_borg_backup
|
||||
- name: Fail if no containers are specified
|
||||
ansible.builtin.fail:
|
||||
msg: "You have to specify at least one container"
|
||||
when: containers_to_stop_start | default([]) | length == 0
|
||||
|
||||
- name: Fail if borg repo name is not specified
|
||||
ansible.builtin.fail:
|
||||
msg: "You have to specify a borg repo name"
|
||||
when: borg_repo_name | default("") | length == 0
|
||||
|
||||
- name: Fail if borg_password is not specified
|
||||
ansible.builtin.fail:
|
||||
msg: "You have to specify a borg password"
|
||||
when: borg_password | default("") | length == 0
|
||||
|
||||
- name: Fail if no directories have been specified for backup
|
||||
ansible.builtin.fail:
|
||||
msg: "You must specify at least one directory to backup"
|
||||
when: directories_to_backup | default([]) | length == 0
|
||||
|
||||
- name: Stop containers
|
||||
community.docker.docker_container:
|
||||
name: "{{ item }}"
|
||||
state: stopped
|
||||
loop: "{{ containers_to_stop_start }}"
|
||||
|
||||
- name: Attempt to trigger a borg backup
|
||||
ansible.builtin.shell:
|
||||
cmd: >
|
||||
export BORG_PASSPHRASE={{ borg_password }};
|
||||
borg create --stats --progress --compression lz4
|
||||
ssh://borg@10.42.0.3:2222/var/backups/borg/{{ borg_repo_name }}::{now:%Y-%m-%d-%H-%M-%S}
|
||||
{{ directories_to_backup | join(" ") }}
|
||||
register: borg_backup
|
||||
async: "{{ borg_async_time }}"
|
||||
poll: "{{ borg_poll_time }}"
|
||||
|
||||
- name: Start containers
|
||||
community.docker.docker_container:
|
||||
name: "{{ item }}"
|
||||
state: started
|
||||
loop: "{{ containers_to_stop_start | reverse | list }}"
|
||||
Reference in new issue
Block a user