12

There are few subfolders in my project folder that wouldn't need to be synced to the guest machine. (In particular the .git folder, which contains >800 files.) Is there a way to unsync subfolders of a synced folder in Vagrant? Or how should I prevent unneeded folders from being synced?

Disabling sync this way doesn't seem to work, when /vagrant/ is synced by default:

config.vm.synced_folder "www/kisa/.git/", "/vagrant/www/kisa/.git/", disabled: true

2 Answers 2

5

Normally (with vboxsf, vmhgfs, NFS, ...) the syncing is done by mounting the specified directory from the host to the guest. For performance reasons there should be no need to prevent some content from "syncing", as the data is not transferred unless you access it from the guest. If you write the data on the guest but don't want to sync it back to the host, easiest is to write it somewhere else. =)

The upcoming Vagrant 1.5 will include rsync synced folders which will support rsync__exclude option. Some cloud provider plugins (aws, digital_ocean, ..) already use rsync, but support for excluding depends on the provider. In some cases you just have to sync only the wanted folders separately. You can disable the default sync with

config.vm.synced_folder ".", "/vagrant", disabled: true
1
0

I can't pretend to understand this, but the method shown at this. seems to work for me for a Linux (Ubuntu) guest on a windows 7 host.

I wanted to use it for exactly what he describes - to exclude a node_modules directory from being shared.

In case the link disappears the gist is:

$ mkdir ~/vagrant_node_modules
$ sudo mount --bind ~/vagrant_node_modules /vagrant/node_modules

so that /vagrant is shared but /vagrant/node_modules is not.

Someone more knowledgeable than me might know if there are problems with this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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