Using Dropbox to sync Local sites between computers under Local Classic

Hello everyone. I would very much like to get local working with dropbox. I am able to have both installs of local look at the same folder so my theme and plugin files are synced but the database doesn’t seem to be synced. I am out of my depth but what is the file in app/public/sql/local.sql? Is that not the database? Shouldn’t that also be syncing?

Thanks.

The file you have discovered is indeed the database. Or, rather, it is a copy of the database as it stood when your site was stopped in Local. But it isn’t the working copy of the database. That’s stored elsewhere. Getting that to sync is what all the business with Terminal is about.

If you want to sidestep all that, you can sync your database manually in a couple of different ways:

  1. One way is to import the database copy that you have found app/public/sql/local.sql. You can do this using Sequel Pro, which you can download and then open from inside Local. You might have to delete all the tables in the database before importing. Or maybe you can just overwrite.
  2. Another way is to use a backup plugin (UpdraftPlus is a good one) to make a backup of your database on computer A, and then restore it on computer B.

I prefer method 2 because you always have a backup. But you do have to remember to backup computer A before you switch to computer B.

Okay! I’ve tried the database sync method described by @hellojd above. It works perfectly!!!

I did it a little bit differently on my setup, though. I began with an existing site folder that I was already sharing between two computers on a cloud drive (iCloud for now, although see my cautions about iCloud above). I created it in the following way:

  1. Create a site in Local on Computer A, with the site path on the shared drive.
  2. Hide the site folder that was just created by moving it inside another folder (or just delete it – see below).
  3. Create a site in Local on Computer B, with the site path in exactly the same location as the site you created on Computer A.
  4. Delete the hidden folder. You no longer need it because Local on both computers will use the same site folder on the shared drive (the one you created from Local on Computer B).
  5. If you’ve already got a working site from computer A on the shared drive and you want to be able to access it from Computer B, then instead of deleting the site folder from Computer A, delete the one you’ve just created from Computer B and unhide the one from Computer A.
  6. If the existing site from computer A is not on the shared drive and you want to have a single shared site folder, then export the site on computer A to a zip file (right click the site in Local and choose "Export) and then reimport it with a site path on the shared drive (choose “Advanced Options” when you import the site).
  7. If you’re doing all this on iCloud be careful that the cloud is updated with all the file operations before you continue or you may find that your local files are being overwritten by older files not yet deleted from the cloud. iCloud can be slow about file operations (see my caution above). If you’re not sure, go to your iCloud Drive at iCloud.com and do the file operations there.

Now, you could just stop here and sync the databases manually as I described in the previous post. But if you want to go farther and sync the databases automatically, as described by @hellojd above, it’s a simple two-step process.

1. On Computer A, find the mysql folder and drag it to the site folder on the shared drive.

  • It’s located in /Users/Username/Library/Application Support/Local/run/G0xUGB4jj where “G0xUGB4jj” is the unique, randomly generated name of the folder containing the database for your site. The name of your folder will, of course, be different.
  • You can find the name and location of your database folder by clicking the Database tab in Local and looking under “Socket”.
  • If the Library folder doesn’t appear in your User folder, right click inside the User folder and choose “Show View Options” and select “Show Library Folder.”
  • Open the folder (“G0xUGB4jj”) that contains your database. Inside this folder is a folder named “mysql.” This is the folder you want to sync.
  • Move the mysql folder to the site folder on your shared drive. Don’t worry about keeping a copy of it in its original location. You don’t want it there anyway, because you’re going to replace it with a symlink to its location on the shared drive. If it doesn’t disappear when you drag it to the shared drive, then delete it (just make sure it’s present on the shared drive first).

2. Create the symlink.

  • A symlink is a UNIX feature that is similar to a MacOS alias. Unlike an alias, it can’t be made from within the Finder. You have to use Terminal. But for this purpose an alias won’t work (at least it didn’t for me).
  • Open the Terminal app
  • Type ln -s
  • Drag the mysql folder from the shared drive into Terminal to copy its location
  • Drag the database folder (e.g. “G0xUGB4jj”) into Terminal to copy its location
  • You should now see something like this in Terminal: ln -s path/to/shared/folder/mysql Users/Username/Library/Application\ Support/Local/run/G0xUGB4jj (or whatever your folder is called).
  • When you press Return, UNIX will create a symlink inside the G0xUGB4jj folder. Open up the folder and see. It looks just like an alias, with a little arrow in the lower left corner, but it’s really a UNIX symlink.

You should now be able to run Local normally. Start the site and it should work just like a normal installation.

On Computer B, the process is the same, except that in step 1 you’re just going to delete the mysql folder from the “G0xUGB4jj” folder rather than copy it to the shared drive. You’ve already got a copy of mysql on the shared drive from Computer A. Local will use that one for both computers. You’ve still got to create the symlink, though, so step 2 on Computer B is just the same.

If everything is as it should be you should now be sharing the database on the two computers. It actually takes less time to do than it does to describe it.

Try running the site from each computer, one at a time, to check your work. Remember not to run the site on both computers at the same time or you’re likely to run into database conflicts. You don’t have to quit Local, just stop the site on Computer A before you start it on Computer B.

Finally, if these are not both new sites (i.e., if you’re creating a copy of an existing site on a different computer), make sure that it is indeed the database from Computer A that you want to share with both computers before deleting the mysql folder from Computer B.

1 Like

Thank you so much for such a considered and thorough reply. Of course I wish it could just be synced as easily as any other file. That said, I will try some of these ideas. Best regards.

Man this seems like such a convoluted way to do it. I am surprised that Local has not put this into the software since it gets talked about so much. This is the main reason I am still using MAMP Pro. If they brought in this feature and it worked as easy as MAMP Pro does I would never touch it again.

Please, can’t one of the wizards at Local add this feature for us? I for one would be more than willing to pay a yearly fee. I often switch from my desktop in my home office to my laptop when I’m out and about. Pushing and pulling from a live site just for the sake of this, when other solutions like MAMP Pro have had this capability for years, feels clunky and wrong, not the future.

2 Likes

Hi @MikeThomasDev!

Thanks so much for the feedback and I am happy to say this request is already on our radar! If you haven’t already upvoted this request on our public feature request board I’d recommend it. We use this board to help us prioritize work.

Also, would you mind sharing how you accomplish this with MAMP? This info will really help our team understand what we could be doing to make this workflow possible for you!

I switch between machines and OSes frequently. I found it easier to use docker to bring up sites, work on them, save them and bring them down with files saved and synced in dropbox. Its as easy as docker-compose up.

The easiest method is to use the docker-compose.yaml on this site:

I have forked that code to add mailhog and a plugin that works with mailhog (there are also some experimental features that can be ignored). That system is here:

It would be ideal if local could just launch a site from a folder in dropbox without any issues or hoops to jump through. Until then, Docker is easier.

Thanks for those links! Are there specific OSes that you are using? I’d especially be interested if you are syncing between Windows and a more Unix-y OS like Mac or Ubuntu (or other!)

One other aspect of this – are you ever working on two computers at once, or are you always shutting down the docker containers before going to work on the other machine?

It looks like the nezhar/wordpress-docker-compose repo stores the raw database files in a folder called wp-data after the site is docker’d up. I’d be curious if you ever run into issues with the raw DB tables being corrupted due to syncing with Dropbox.

I use Linux Mint primarily, followed by MacOSX, and Windows when I have to. It is better on Windows now that Docker is integrated with WSL2. All of the same scripts work.

When I create a new site, I increment the external port numbers by 1. That way, I can work on multiple sites at the same time on “localhost”. If I run the WP container on port 80, I can give access to the LAN, or the Internet to share the site. I also use ngrok for this purpose.

It would not be advisable to work on the same sites on separate computers at the same time, since you would get sync errors or clobbering.

The WP-data folder stores the entire dB in a SQL script. This is created when you run the export.sh script. It is advisable to run this frequently while working on a site. This way you have previous versions of the DB. I also make file backups, but having the site and dB in Dropbox means that you have automatic versioning and backups. The SQL script is loaded as soon as you run Docker-compose up.

Once in a long while the SQL doesn’t load and I have to reload it with PhpMyAdmin or an import script (the opposite of the export script).

1 Like

Thank you! This still works great for me via Dropbox between two macOS Big Sur PCs.

1 Like

I have a Mac laptop and a Windows Desktop. Has anyone tried to do a setup like this? I am thinking it is not possible as the file structures are different…?

This might be tricky if you are trying to sync the actual “run” folder (ie the raw DB files and server config) if you are just syncing the Local Sites folder, then it might be easier.

The new Cloud Backups add-on doesn’t sync between computers at this time, but being able to sync a site is on the radar for improvements to the add-on and should be worked on soon. To be specific – syncing a site would be creating a backup on one machine and restoring on another.

Thanks @ben.turner . This would indeed be a cool feature if baked in. Maybe syncing just the Local Sites folder would at least save some time.

@ben.turner That’s awesome to hear that some form of syncing between systems would be possible in the future. I know that currently it’s just Google Drive and Dropbox being support, any chance that OneDrive might be included in the future?

Maybe? :smiley: I honestly don’t know what all is involved, but as a starting point, can you create a new feature request for having the Local Cloud Backups add-on support OneDrive?

Be sure to up-vote the feature request so that the Local team an get an idea of how interested the community is in the feature!

1 Like

Great! I’ll do that right now. Thanks Ben! :slight_smile:

2 Likes

@ sc0ttkclark
here’s another solution which at least works for me:
I use 2 Macs (Mac mini and Macbook) and I sync my sites using Resilio Sync (File Sync Software - Sync Home | Resilio Sync). It is 60$, I bought it on Black Friday for half the price.
What did I do ? I installed LocalWP on my Mini, built a website, exported it. Then I installed LocalWP on my MacBook and imported the site.
Now I sync both folders /Users/Username/Library/Application Support/Local and path/to/local/website using Resilio Sync, which runs automatically in the background.
It is important to run only one Installation at a time ( either Mini or MacBook) and you have to wait for syncing being completed, before starting LocalWP on the other machine.
With this set up I work for several weeks no without any problems.

I am not a native speaker (obviously) but I hope you understand, what I did.
Cheers, Michael

Hi,

Please, can OneDrive be used for the same purpose to sync local sites between computers under local classic since it is already install on my local machine which syncs to OneDrive and as such a virtual folder would have been created so I am just wondering if my team and I can work from different computers and backup onto same folder on OneDrive?

Picking this thread up to see if anyone can see any holes in this workflow I’m trying to figure out for working between two computers on a daily basis:

  1. Open Local, create a new site in a Dropbox folder
  2. Install UpdraftPlus and schedule DP backups every few hours
  3. Finish working on theme files etc
  4. Install WP Migrate Lite and create an export zip
  5. Save zip file on Dropbox
  6. Open second machine
  7. Move/delete existing setup folder out of the Dropbox folder
  8. Drag exported zip into Local
  9. Setup zip as a new site in the same Dropbox folder location as the first setup
  10. Make sure UpdraftPlus is installed and scheduled to backup
  11. Leave both installs running and when moving from one to the other import the most recent db backup file if there have been any changes to files other than the theme files (uploading media, making new posts/pages etc)

I’m hoping this will work but I’m not sure if deleting the original files from the first setup and them being replaced by exact copies from the exported backup zip will actually work in practice. Has anyone else done this? Am I overthinking/overcomplicating it?