Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rsync not respecting rsync__exclude on *initial* sync #4248

Closed
sursh opened this issue Jul 24, 2014 · 8 comments
Closed

Rsync not respecting rsync__exclude on *initial* sync #4248

sursh opened this issue Jul 24, 2014 · 8 comments

Comments

@sursh
Copy link

sursh commented Jul 24, 2014

I'm trying to get Vagrant to sync . to /vagrant, as is the default behavior, except for a few folders that I'd like to exclude. I'm finding that rsync is NOT respecting rsync__exclude on first sync when the VM is created, but seems to be working on subsequent rsyncs.

I'm following along with this documentation. I added an exclude line to my Vagrantfile:

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "aws"

  # Relevant bit:
  config.vm.synced_folder ".", "/vagrant", type: "rsync", rsync__exclude: [".git/", "data/"]

  config.vm.provider :aws do |aws, override|
    # etc ..... 

I know that rsync sees this, since running vagrant rsync gives the following output:

$ vagrant rsync
==> default: Rsyncing folder: /Users/sasha/code/client-name/ => /vagrant
==> default:   - Exclude: [".vagrant/", ".git/", "data/"]

and when I blow away the contents of /vagrant and re-rsync with vagrant rsync, those files & folders are not recreated, as expected.

However, when the machine is initially created, the exclude is NOT respected and .git/ and data/ are copied over. Here is the relevant output from that process.

==> default: Waiting for instance to become "ready"...
==> default: Waiting for SSH to become available...
==> default: Machine is booted and ready for use!
==> default: Rsyncing folder: /Users/sasha/code/LTV/ => /vagrant
==> default: Running provisioner: shell...

and when I ssh into the box:

ubuntu@ip-x-x-x-x:/vagrant$ ls d
data/    
ubuntu@ip-x-x-x-x:/vagrant$ ls .git
.git/       .gitignore  

What's going on here? Why the different behavior? And can I get the initial rsync to exclude certain folders?

@davidstacy
Copy link

I believe I am seeing this same behavior for two of our developers. We are working around the issue but would like to make sure that the excluded directories are never rsynced.

@sursh
Copy link
Author

sursh commented Aug 5, 2014

@mitchellh should this issue be here or in vagrant-aws? happy to move it over

@mitchellh
Copy link
Contributor

@sursh The AWS provider doesn't use the core rsync synced folder (they/me implemented their own). I don't actively maintain it currently but you should open a bug there, there are other comitters that should fix this. Thanks!

@sursh
Copy link
Author

sursh commented Aug 13, 2014

For anyone else with this problem, there is an undocumented way that works: mitchellh/vagrant-aws#156

@sursh
Copy link
Author

sursh commented Aug 13, 2014

@davidstacy ^

@dustMason
Copy link

@mitchellh I'm seeing this behavior while using the virtualbox provider as well. Same as described above: vagrant rsync respects my rsync__exclude setting while vagrant rsync-auto does not.

app.vm.synced_folder config.user.paths.something_repo, "/var/www/something",
  type: "rsync", owner: "www-data", group: "www-data",
  rsync__args: ["--verbose", "--archive", "-z"], rsync__exclude: ["build"]

@bartclarkson
Copy link

@dustMason, your issue might (or might not) be related to #4567 . I started on this thread.

@trompx
Copy link

trompx commented Apr 9, 2015

I have the same problem : Vagrant 1.7.2
My Vagrantfile is in a websites folder :

  • websites
    • project_1
    • project_2

When for example I work on project_1, I rsync websites, exlcude project_2 and exclude project_1/node_modules.

I want to only install node modules on the VM, it works when I vagrant up on initial rsync, but as soon as I "vagrant rsync-auto" the exclude project_1/node_modules is not respected and my VM node_modules folder is removed (as not present on the host).

If I then "mkdir node_modules" in project_1, it is not removed in the VM as expected.

Any update or solution for respecting the exclude on initial vagrant rsync-auto ?

Thank you

@ghost ghost locked and limited conversation to collaborators Apr 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants