Entrepreneur, WordPress Enthusiast & Digital Marketing Strategist

Syncing VVV over Dropbox to develop anywhere (The Better Way)

Using VVV and vagrant environments is immensely helpful for development but it can be a pain when you work from multiple locations like me. From my desktop at home to my laptop on the run I want to be able to work on the same environment. When first investigating this issue I came across a really helpful article by Josh Pollock that got me going with syncing VVV over Dropbox (http://joshpress.net/using-dropbox-keep-vvv-sync-multiple-computers/). After using the setup for a while I discovered there were a few problems with syncing the entire VVV folder over Dropbox. This article will go over these issues and how I resolved them.

The Issues

Vagrant/Virtualbox would get confused sometimes and either would get stuck trying to boot the VM or create a brand new one. On occasion, this could cause work done to the database to be lost on old VMs and would be a real pain to recover. Josh also appeared to have had these issues as he has added some footnotes to his own article since I first read it documenting similar issues. Digging into this further I’m confident the issue lies in the .vagrant folder which tells vagrant the details of the VirtualBox VM to use. On different machines the VM IDs are different which is what gives us our problems.

 

The Solution

The only parts of VVV we are working on and changing regularly are the ‘www’ and ‘database’ folders, the rest remain mostly static. So if we store our VVV folder locally (I chose C:\VVV for ease of access) and symlink out those two folders we need to sync to Dropbox then we shouldn’t run into issues. Apparently easier said than done.

At first I tried the symlinking the direct www/database folders like so:

mklink /J C:\VVV\www D:\Dropbox\VVV\www

Upon trying to boot the VM with this symlink it kept failing to mount the shared folders. After a bunch of digging I found that for some reason VirtualBox has an issue with mounting a junction (symlinked folder) however it can follow the junction. So instead I put the www and database files in Dropbox into a subfolder (called files for lack of a better term) and used the following symlink:

mklink /J C:\VVV\www\files D:\Dropbox\VVV\www\files
mklink /J C:\VVV\database\files D:\Dropbox\VVV\database\files

Then you need to edit your Vagrantfile to match these path changes:

With that change I was able to boot and provision the VMs successfully on both machines.

I’m sure this method could be tweaked and my file path changes aren’t elegant but it’s working great so far and I haven’t had any issues with vagrant forgetting the VMs or having to rebuild the VM.

Categories: Wordpress, Workflow

Comments

Your email address will not be published. Required fields are marked *