rsync is deleting files from target folder unexpectedly

I added a synchronised folder to my VagrantFile using rsync with no arguments or options, e.g.

config.vm.synced_folder ".", "/vagrant", type: "rsync"

My local folder has X files and folders and the VM target folder has X and Y files and folders. When rsync runs it deletes Y files and folders from the VM target folder which is not what I wanted to happen.

Everywhere I've looked says rsync doesn't do this by default and you would need to use the --delete option so I'm wondering if it's something to do with how Vagrant uses it

Does anyone know how I can ignore the files already there? It would be nice if rsync detected when I deleted something from the local folder and then removed on the VM but I want to keep what's already there if possible.

**Edit**: turns out it is in the vagrant guidance that it uses a set of args when it loads rsync which includes --delete:

["--verbose", "--archive", "--delete", "-z", "--copy-links"]

I can override the args easily enough.

Leave a Comment