1

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?

tbraun89
  • 111
  • 6
  • 2
    This seems overly fragile. Have you considered using the Ansible fetch module? – EEAA Oct 27 '15 at 12:46
  • Yes, but the reason I try to do it this way is, because I don't want to create any files on `SERVER 1..n`, with the fetch module I need to create a temporary archive on `SERVER n` fetch it on the `BACKUP_STORE` and delete it on `SERVER n` this I'd like to avoid using netcat. – tbraun89 Oct 27 '15 at 12:50
  • 1
    Seems like it would be worth switching to something like duplicity for your backups. You could still use Ansible to start the backup jobs if wanted, but it would be much more reliable. – EEAA Oct 27 '15 at 13:01
  • 1
    I don't think that Ansible is the right tool to the job. It would be best if you use a tool like Bacula/Amanda or even a simple tool like backup-manager. – Stefano Martins Oct 27 '15 at 13:48
  • I now use duplicity in combination with Ansible, so I can integrate it with other Ansible roles and manage the servers and settings easily. – tbraun89 Oct 28 '15 at 09:31

0 Answers0