# synchronize module does not sync from remote to local

**URL:** <https://forum.ansible.com/t/synchronize-module-does-not-sync-from-remote-to-local/13892>\
**Category:** Ansible Project\
**Created:** [November 12, 2013, 4:06pm UTC](https://forum.ansible.com/t/synchronize-module-does-not-sync-from-remote-to-local/13892 "2013-11-12T16:06:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Edgars](https://avatars.discourse-cdn.com/v4/letter/e/f17d59/32.png) [@Edgars](https://forum.ansible.com/u/Edgars)\
**Post date:** [November 12, 2013, 4:06pm UTC](https://forum.ansible.com/t/synchronize-module-does-not-sync-from-remote-to-local/13892/1 "2013-11-12T16:06:13Z")

</div>

Hi

I have some troubles to understand how synchronize works… Here is what I have:

---

<div class="post-metadata">

**Author:** ![tannerjc](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/tannerjc/32/985_2.png) [@tannerjc](https://forum.ansible.com/u/tannerjc)\
**Post date:** [November 12, 2013, 4:09pm UTC](https://forum.ansible.com/t/synchronize-module-does-not-sync-from-remote-to-local/13892/2 "2013-11-12T16:09:50Z")

</div>

The src host is defined by your inventory host. So if "hosts: localhost", then rsync will run from localhost. The dest path is also on the the inventory host by default, so again if "hosts: localhost" then dest will be \<user\>@localhost:\<path\>.

That being said, if you want to rsync to another machine, you can put \<user\>@\<hostname\>:\<path\> for your dest parameter.

Make sure that the user on the src host can connect to the the dest host via ssh key or rsync won't be able to authenticate.

---

<div class="post-metadata">

**Author:** ![Edgars](https://avatars.discourse-cdn.com/v4/letter/e/f17d59/32.png) [@Edgars](https://forum.ansible.com/u/Edgars)\
**Post date:** [November 12, 2013, 4:19pm UTC](https://forum.ansible.com/t/synchronize-module-does-not-sync-from-remote-to-local/13892/3 "2013-11-12T16:19:27Z")

</div>

Hi

I want to rsync from another server to localhost.

From documentation:

"# Synchronization of src on delegate host to dest on the current inventory host

```auto

synchronize: >
    src=some/relative/path dest=/some/absolute/path

```

delegate\_to: delegate.host"

So I have source on delegate host (dbserver) and dest on the current inventory host, which is localhost. But it does not sync back to localhost.

Edgars

otrdiena, 2013. gada 12. novembris 17:09:50 UTC+1, James Tanner rakstīja:

---

<div class="post-metadata">

**Author:** ![tannerjc](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/tannerjc/32/985_2.png) [@tannerjc](https://forum.ansible.com/u/tannerjc)\
**Post date:** [November 12, 2013, 4:39pm UTC](https://forum.ansible.com/t/synchronize-module-does-not-sync-from-remote-to-local/13892/4 "2013-11-12T16:39:48Z")

</div>

If you are gathering facts, you can do this ...

- hosts: localhost  
&nbsp;&nbsp;&nbsp;gather\_facts: True  
&nbsp;&nbsp;&nbsp;tasks:

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- synchronize: src=/tmp/foosrc dest=root@"{{ ansible\_default\_ipv4.address }}":/tmp/foodest  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;delegate\_to: el6.lab.net

Just tested, and it works if el6.lab.net has an ssh key on localhost.

---

<div class="post-metadata">

**Author:** ![Timothy\_Appnel](https://avatars.discourse-cdn.com/v4/letter/t/e5b9ba/32.png) [@Timothy\_Appnel](https://forum.ansible.com/u/Timothy_Appnel)\
**Post date:** [November 18, 2013, 10:11pm UTC](https://forum.ansible.com/t/synchronize-module-does-not-sync-from-remote-to-local/13892/5 "2013-11-18T22:11:00Z")

</div>

The whole point of the synchonize module was to avoid all of this mess otherwise you may as well use the command action and craft your own rsync command.

You never have to specify the host in the src or dest. Depending on a combination of variables – connection, invetnory host and delegate host if any – the module does that for you.

Also, if I’m reading Edgars question and James’ solution correctly the src and destination is flipped in both cases.

- hosts: {{ database\_server }}

tasks:

- synchronize: src=/opt/dbbackup dest=/backup/dbbackup mode=pull

Here files in /opt/dbbackup on the host defined by database\_server will be synchronized to /backup/dbbackup on the localhost.
