ansible-role-openstack-oper.../tasks/backup_filesystem.yml

37 lines
1.0 KiB
YAML

- name: Remove any existing backup directory
file:
path: "{{ backup_tmp_dir }}/filesystem"
state: absent
- name: Create a new backup directory
file:
path: "{{ backup_tmp_dir }}/filesystem"
state: directory
- name: Backup files and directories
shell: |
/bin/tar --ignore-failed-read --xattrs \
-zcf "{{ backup_tmp_dir }}/filesystem/{{ inventory_hostname }}-{{ backup_file }}" \
{% if backup_excludes is defined %}
{% for backup_exclude in backup_excludes %}
--exclude {{ backup_exclude }} \
{% endfor %}
{% endif %}
{{' '.join(backup_dirs) }}
ignore_errors: yes
delay: 60
- name: Copy the archive to the backup server
synchronize:
mode: pull
src: "{{ backup_tmp_dir }}/filesystem/{{ inventory_hostname }}-{{ backup_file }}"
dest: "{{ backup_directory }}"
set_remote_user: false
ssh_args: "{{ backup_host_ssh_args }}"
delegate_to: "{{ backup_host }}"
- name: Remove any existing backup directory
file:
path: "{{ backup_tmp_dir }}/filesystem"
state: absent