When doing vagrant up a "shell" provision download some files into the synced folder. Those files should be also copied to the host machine synced folder, so that the project would be available from the host. When using the NFS to sync, this is done automatically, but not with rsync. Is there any way to achieve this using rsync with Vagrant? This is the synced folder configuration:

config.vm.synced_folder "./", "/vagrant", type: "rsync", owner: "www-data",
rsync__exclude: [".git", "project1/app/cache", "project1/app/logs"],
rsync__args: ["--no-owner", "--verbose", "--archive", "-z", "--copy-links"]

According to the Documentation, rsync is only a one-way synchronization in vagrant. This means that you either have to use a different mechanism like nfs for a sync back from the guest to the host or else that you'd have to implement some back-sync mechanism of your own like running a rsync command manually on the host.

One might write a rsync-back extension(plugin) to vagrant. I am not aware of an existing plugin to achieve that.

If the virtualbox guest extensions are installed in your guest, you might also want to take a look at the virtualbox shared folder mechansim vboxsf as a transport for varant's synced folder instead of nfs and rsync.

| improve this answer | |

These are the commands to sync from guest to host, and they should be executed from the folder where you ran vagrant up:

$ vagrant ssh-config > ssh_config
$ rsync -avH -e "ssh -F ./ssh_config" default:/vagrant/ ./

See also this answer I wrote on stackoverflow.

| improve this answer | |

If your guest and host have ssh, you can use scp to transfer data bidirectional.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.