I use
MAMP as my local development environment. MAMP is brilliant as it installs the software (Apache, MySQL and PHP) used to run a web server similar to a LAMP server. This is great as it means you can test your files locally without having to upload them first. As I work between a MacBook and an iMac I was looking for a away to keep my projects in sync between the 2 machines. I turned to
Dropbox which is a service that synchronises a folder on your computer over the internet.
I created a directory called sites in my Dropbox folder and then added my projects in here. All my projects are now sync'd on both machines but if I make any changes to the Database I've got to do this on both machines. You can use Dropbox to sync your databases as well. This isn't the most ideal solution as you can run into some problems, especially if are running both versions of MAMP simultaneously. I've been using this solution for about a year now and not run into any major problems so until I find a better way I'll continue to do so.
To sync your database you will need to move the MAMP db folder to dropbox and then create a symbolic link in the MAMP folder back to the db folder in the dropbox. Before starting make sure your MAMP servers are turned off, then open up terminal and enter.
cd ~/Dropbox/
cp -r /Applications/MAMP/db MAMP_DB
rm -rf /Applications/MAMP/db
This will change the directory to your Dropbox folder, then copy the MAMP db folder to dropbox and remove it from the MAMP directory. Then we have to setup the symbolic link.
ln -s ~/Dropbox/MAMP_DB/db /Applications/MAMP/db
Passing the -s option to the
ln command will create a symbolic link, we then pass source file and the target file. And that's it, restart your MAMP servers and you should be syncing your databases to Dropbox. You will need to run the last 2 commands on any other computers you have MAMP installed.
If two of your MAMP installs update the same file at the same time, the 2nd to finish will not overwrite the existing file it will instead create a
conflicted file, to fix this you just need to determine which file has the correct data and delete the other (removing the conflicted message in the file name).
This can cause some problems with your MySQL databases, if you are noticing missing data this is the first place to check. You should keep an eye on the ~/Dropbox/MAMP_DB/db/mysql folder, especially the ibdata1 file as this can be quite large and having multiple copies of this file can quite quickly use up all your of Dropbox space.