Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vagrant 2 way folder sync

I've setup a Vagrant box that runs my webserver to host my Symfony2 application. Everything works fine except the folder synchronization.

I tried 2 things:

  1. config.vm.synced_folder LOCALFOLDER, HOSTFOLDER
  2. config.vm.synced_folder LOCALFOLDER, HOSTFOLDER, type="rsync"

Option 1: First option works, I actually don't know how file is shared but it works. Files are copied in both way, but the application is SUPER slow. Symfony is generating cache files which might be the issue, but I don't really know how to troubleshoot this and see what is happening.

Option 2: Sync is only done in one way (from my local machine to the vagrant box), which covers most of the case and is fast. Issue is that when I use symfony command line on the vagrant box to generate some files they are not copied over to my local machine.

My question is: What is the best way to proceed with 2 ways syncing? With option 1 how can I (as it might be the issue) exclude some files from syncing. With Option 2 how can I make sure changes on remote are copied to my local machine?

like image 894
LEM01 Avatar asked Mar 19 '23 04:03

LEM01


1 Answers

If default synced folder strategy (VirtualBox shared folders, I imagine) is slow for your use case, you can choose a different one and, if you need, maintain the two-way sync:

  • If your host OS is Linux or Mac OS X, you can go with NFS.
  • If your host OS is Windows you can instead choose SMB.

Rsync is very fast but, as you've pointed out, is one-way only.

like image 123
Emyl Avatar answered Mar 29 '23 02:03

Emyl