Dropbox Database Sync for Testing


By: | Date: Category: Freebies, Tutorial

Database management is very important, but it's always presented a problem.

Dropbox Database Sync for Testing

Keeping computers in a local testing environment in sync can be a nightmare. Creating a Dropbox database sync is an ingenious, often overlooked approach to this daunting problem.

We will start off assuming your testing environment is already established. If you haven't gotten to that step yet, please refer to our MAMP tutorial. MAMP (much like LAMP or XAMP) is simply an acronym for Apache, MySQL, PHP and it's important to keep that in mind while we push forward. What we're looking to address in this tutorial is your MySQL database. More specifically - We will be creating a SQL database on Dropbox then tricking MAMP into using that (instead of the default /db folder).

Adding Dropbox

Dropbox is an amazing tool, even if you're not a dev nerd. You can get started by setting up a free account at http://www.dropbox.com, but put simply - Dropbox is online storage that is easily accessible through multiple devices. As long as your account is setup, we can move forward and create the dropbox database sync that you will know be using.

Creating your Dropbox Database

Open your Terminal application from the "Applications/Utilities/" folder. Make sure you're MAMP server is off, then we'll be doing the following tasks inside Terminal…

  1. Set your directory to Dropbox
  2. Move the current MAMP database to Dropbox
  3. Remove the old MAMP database folder
  4. Create a symbolic link in your MAMP folder to your Dropbox database folder

Each of those steps can be achieved with the corresponding Terminal commands below...

cd ~/Dropbox/
cp -r /Applications/MAMP/db MAMP_DATABASE
rm -rf /Applications/MAMP/db
ln -s ~/Dropbox/MAMP_DATABASE/db /Applications/MAMP/db 

As with everything in Terminal, be deliberate and take your time. Also note that the name "MAMP_DATABASE" is arbitrary. If you prefer a different name feel free, just make sure you use the exact same name in both lines (2nd & 4th) and adhere to the normal naming rules (alphanumeric and underscores). Once you've got everything setup, clear your browser cache, and start your MAMP application. I'd suggest making sure you click on your PHP admin tab at the top, since most errors will result in a missed connection there.

As long as everything is up and running, we can give one last sync, back everything up, and then add additional computers to the mix...

Make Dropbox Sync

MAMP Error ScreenshotThat's the easy part! Make sure your Dropbox server is off (you obviously don't want to sync while you're using a database) then start your Dropbox application. Since your SQL database is in your Dropbox folder, simply sync Dropbox, and you're good to go. The only issue's I've run into using this setup are the normal "conflicting" errors that you occasionally get with any syncing application (see image). As long as you only sync one computer at a time, this shouldn't be a problem. If you do see those errors, just make sure you delete the appropriate "conflicting" files, and you're good. Which brings me to the final step...

Adding Computers to your Dropbox Database sync setup

The Terminal commands we used earlier are useful in this situation, but we certainly don't want to just overwrite the existing Dropbox database - We want to use it. This can be achieved with the following steps…

  1. Set your directory to Dropbox
  2. Remove the old MAMP database folder
  3. Create a symbolic link in your MAMP folder to your Dropbox database folder

Each of those steps can be achieved with the corresponding Terminal commands below...

cd ~/Dropbox/
rm -rf /Applications/MAMP/db
ln -s ~/Dropbox/MAMP_DATABASE/db /Applications/MAMP/db 

Enjoy Your Cutting Edge Setup

Dropbox Database Sync ScreenshotThat's it - Not as tricky as you thought right? If you do run into any issues (and if you're a newbie, you will) make sure you take a look at your error logs and the structure of your folders. One thing you can do to confirm that your Terminal commands were entered properly is to simply look at your Applications/MAMP folder. You should see the small folder icon with the arrow underneath (see image) where your db folder used to be. In your Dropbox folder you should see your new database folder, which in this example would be named MAMP_DATABASE. If anything looks wonky in these places, adjust your approach.

Now throw a stranger a high-five because you have an AWESOME tool for your testing environment. No more importing, exporting, and ending up with spare database backups everywhere… It's all in one place! We've got a few ways to expand on this concept (that we'll be posting soon), but as for a solid method of keeping your databases synced - this is a dead simple and rock solid approach. If you have any questions or ideas on how to build on this concept please leave them below and if you like this tutorial share it on your favorite social network… and congrats! Now go have fun.

Hits: 3577
    • 10 Responsive Frameworks You Need

      Bootstrap vs Gumby vs Foundation - We take a look inside all the popular frameworks on the market and find the 10 Responsive Frameworks You Need.

    • Dropbox

      Some terms scare people off. Cloud computing may seem like some far off, nerd driven technology. Dropbox makes it easy as pie.

    • MAMP Basics - Build a Local Environment

      A testing server is an important tool for any designer or developer. This web development tutorial will show you how to install MAMP and get it running in no time.

    • Optimizing Development Workflows

      Efficient workflows and workflow patterns are key to effective web development. Learn how to streamline your workflow with this web development tutorial.

  • A little about the author...

    Matthew Haeck
    Matthew Haeck

    Matthew Haeck is the lead designer and developer at Haeck Design. His educational background in both Graphic Design and Economics prepared him perfectly to operate the design firm which bares his name. When not working, Matthew enjoys curating his growing vinyl collection, hitting the beach, and supporting his beloved hometown of Raleigh, NC.

Comments (2)

  • Peter Mottman
    Peter Mottman
    29 October 2013 at 15:58

    Can you put the root folder on your desktop and just use it that way?

    reply

  • Haeck Design
    Haeck Design
    06 December 2013 at 03:12

    Yes, just make sure you include the correct path (usually Computer/Users/Username/Desktop)

    reply

Leave a comment

Click the login buttons below to leave a comment.