4

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"]
Manolo
  • 552
  • 2
  • 8
  • 23

3 Answers3

2

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.

Michael Adam
  • 396
  • 2
  • 7
2

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.

womble
  • 96,255
  • 29
  • 175
  • 230
tonejito
  • 121
  • 3
0

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