One way replication

14 views
Skip to first unread message

BRIT

unread,
Mar 11, 2016, 10:34:40 PM3/11/16
to Vagrant
Does anyone know if it's possible to have "one way" replication set up between the host shared folder and the synced folder on the guest VM?

What I mean is, suppose that you have an Ubuntu guest VM that has the folder /etc which has been configured to sync with the host folder D:\Vagrant\Test\Application\etc.  On the host I have a single .ini file that I would like to be able to easily edit and, of course, that gets synced onto the guest. The problem is of course, that as soon as vagrant loads up the guest VM in the environment and then sets up the synced folder with the host, all of the existing files in the /etc/ folder on the guest are deleted, because they don't reside on the host.

Ideally what I'd like to achieve is to have all the existing files on the guest remain in the /etc/ folder, but have the host files residing in D:\Vagrant\Test\Application\etc to be synced (Host > Guest)

Does anyone know if this is possible?

Alvaro Miranda Aguilera

unread,
Mar 12, 2016, 2:59:02 AM3/12/16
to vagra...@googlegroups.com
Hello,

that folder will be available on the guest as:

/vagrant/Test/Application/etc

Will be easier if you have a shell script that does that copy

cp -a /vagrant/Test/Application/etc/ /etc/


So you can add this:
config.vm.provision "sync", type: "shell", inline: "cp -a /vagrant/Test/Application/etc/ /etc/"

And force a new sync like this:
vagrant provision --provision-with sync

From there you can just adjust the cp command to what you require.

Alvaro.

Reply all
Reply to author
Forward
0 new messages