I try to backup my servers with Ansible. My setup is like this:
SERVER 1..n
(my data I want to backup)
ANSIBLE_HOST
(on this server my Ansible backup playbook is executed by a cron job)
BACKUP_STORE
(on this server my backups are stored)
Now I try to send the files with netcat from SERVER x
to the BACKUP_STORE
my Ansible tasks look like this:
- shell: >
nc -l {{ port }} > {{ backup_file }}.tar.bz2
async: 1000
poll: 0
register: receiver
delegate_to: "{{ BACKUP_STORE_IP }}"
- shell: >
tar -cvpj --one-file-system {{ folder }} | nc -q 0 {{ BACKUP_STORE_IP }} {{ port }}
- async_status:
jid: "{{ receiver }}"
register: job_result
until: job_result.finished
retries: 30
delegate_to: "{{ BACKUP_STORE_IP }}"
When I execute the shell comands on both servers on my own, this works 100% of the time. But If I run them with this Ansible script, about 50% of the time the backup file on BACKUP_STORE
is created but it is empty (0 bytes).
What could be the reason the data is not transmitted when this is run through Ansible? Or is there any other method, sending the file without writing the archive on the filesystem of SERVER x
?