Developer, entrepreneur, drummer, biker, dog owner, husband, and proud dad. Loves Laravel and coffee
Sync htdocs and MySQL data with Dropbox
11/18/2012
I’ve recently made the decision to move away from a PC to a Mac for day to day use and for work/development. This process has been slow so far, but one of the first things that I tackled was being able to sync my web files to all of my computers and also be able to access them locally without having an internet connection, if needed. I use
This article assumes that you are starting on a windows machine and mirroring it to a Mac (or other machine). You can easily reverse these steps if you would like to go the other way too.
Windows:
In Xampp Stop MySQL server
Rename C:\xampp\mysql\data to C:\xampp\mysql\data_old
Copy C:\xampp\mysql\data_old to C:\Users\Chris\Dropbox\Development\db (rename ‘data_old’ to ‘db’)
Run command prompt in Administrator mode
Edit/run the following command: mklink /J C:\xampp\mysql\data C:\Users{USER}\Dropbox\Development\db
Start MySQL – You shouldn’t get any errors and should be able to get to phpMyAdmin (You can delete C:\xampp\mysql\data_old now)
In Xampp > Disable the MySQL service – you do not want this running on start up since you will get errors with Dropbox (using active files)
In Xampp stop the Apache server
Rename C:\xampp\htdocs to C:\xampp\htdocs_old
Edit/run the following command: mklink /J C:\xampp\htdocs C:\Users{USER}\Dropbox\Development\htdocs
In Xampp start the apache server – you should be able to access all of your files now through localhost
Delete C:\xampp\htdocs_old
Mac:
Stop MAMP Servers (if running)
Rename /Applications/MAMP/db/mysql to /Applications/MAMP/db/mysql_old
In the Terminal run: ln -s ~/Dropbox/Development/db /Applications/MAMP/db/mysql
In the Terminal run: /Applications/MAMP/Library/bin/mysqladmin -u root -p password {Your Windows MySQL password here}
Enter the windows MySQL password again
Update the following with the new password:
/Applications/MAMP/bin/mamp/index.php
/Applications/MAMP/bin/mamp/{Language}/index.php
/Applications/MAMP/bin/phpMyAdmin/config.inc.php
Start MAMP servers and check to make sure you can connect
Delete /Applications/MAMP/db/mysql_old
Stop MAMP Servers
Delete /Applications/MAMP/htdocs (if you have any files that you would like to keep, move to your ~/Dropbox/Development/htdocs folder first!)
In the Terminal run: ln -s ~/Dropbox/Development/htdocs /Applications/MAMP/htdocs
Start MAMP servers – everything should be working through localhost now
In Dropbox
You should now have Development/db and Development/htdocs in your Dropbox folder.
Important Notes:
Do not start MySQL on either platform without pausing the sync on Dropbox. Dropbox will not be able to sync the active files that MySQL is using. To re-enable sync, stop the MySQL service first, then resume Dropbox sync.