Updated November 3, 2014 See below for a few issues we’ve come across.
I’ve been plotting for a while now to get a kick-ass desktop for development. Since I work once or twice a week at a co-working space and travel for WordCamps or to visit family fairly regularly, I’m going to need to keep my laptop for those situations. One of the things, besides clients owing me money that has kept me from getting said kick-ass desktop machine is worrying about how to keep my development environment in sync between the two machines.
Lucky for me Scott Kingsley Clark, figured out how easy it is to keep VVV in sync between his shiny new iMac and his laptop. Scott was kind enough to share his strategy with me, which I have tested with a loaner computer and found to work very well.
Before We Get Started
I’m assuming that you’re already using VVV and are familiar with it. If you’re not, you should probably be reading my guide to getting started with VVV for local WordPress development instead.
You can either use an existing VVV setup or create a new one for this. In this guide, I will be starting from scratch, but you could also do the same thing by temporarily moving your existing one into your Dropbox folder instead of creating a new one.
Also, for this guide, I will be calling the vagrant folder dvv, for Dropbox Varying Vagrants. You can call it whatever you want.
Setting It Up
Install VVV In Dropbox
The first step is to clone VVV itself into Dropbox:
git clone https://github.com/Varying-Vagrant-Vagrants/VVV dvv
You could also download the ZIP and extract it in Dropbox.
Symlink VVV Folder
On both computers you are going to want to symlink the VVV folder with a folder in your user root. This is mildly optional, as you could just work out of Dropbox. Personally, I agree with Scott on symlinking, as I love the ease of being able to cd directly into my VVV from a new bash shell. It’s a little thing, but I have to do it after every restart.
If you’re using an existing install, this step is extra important as it let’s you put the install back where you found it on the originating computer.
You must do the symlink on both computers:
ln -s ~/dropbox/dvv ~/dvv
On the remote machine you do a new
vagrant provision and that’s it you’re good to go.
What This Doesn’t Do
This does not keep the virtual machines themselves in sync. I don’t think it makes any sense to do so, though I’m sure it’s possible. That means whenever you make changes to your configuration or add a new site, you will need to do a new
vagrant up on the other computer.
Also, since the database is in the virtual machine. It does not keep the database in sync. If you have the Vagrant Triggers plugin installed you get a database backup every time you
vagrant halt. You can use that to rebuild the DB when doing a new
vagrant up or
That’s Actually Very Simple
That’s it. Turns out this is very simple, Scott’s pretty good at creating ways of making WordPress simpler.
OK, Maybe Not That Simple
Here are some caveats that Scott has discovered since starting to use this strategy since implementing Dropbox to sync his VVV between two computers:
1. My virtual machine tends to be recreated from time to time, forcing 100% install over again when doing a `vagrant up`, this is likely because some files synced by Dropbox are unique to the computer, and keep changing between ‘up’s on the different vagrants.
2. Because of the virtual machine recreation, DB changes can disappear and most commonly be restored by Vagrant during it’s provisioning. It’s important to note that when you use `vagrant halt`, it will backup the databases on the current virtual machine, and on `vagrant up` (first, or `vagrant provision`) it will attempt to restore those DB .sql files on the other machine.
Approach with caution, I currently now believe the best way to sync VVV is to limit the sync to the `www` folder, not the entire VVV folder contents.