Local Community

Using Dropbox to sync Local sites between computers

This is actually a giant step back from using MAMP/XAMP, especially for anyone who has more than a few sites to sync, more than two machines to sync with, who is frequently creating new sites or rarely switches between machines.

Compare with:

  1. Install MAMP on Mac A and point web root to dropbox
  2. Install MAMP on Mac B and point web root to the same folder

… and point the each WP installation to a remote DB, but I suppose that is also needed in the Local setup you describe but isn’t listed as a step. The crucial part is that it syncs all existing and future installs in one go with far fewer steps.

It’s like all the smarts that have gone into Local’s various features are working against it when you want to sync sites. I am going to write a feature request for Local to recognize existing container directory structure. I hope that’s even possible with all the virtualization tech.

1 Like

I’ve tried sharing DBs too back when I used VVV and that wasn’t pretty.

I would like to see Local have the ability to pick up new installs from the “Local Sites” folder (if the folder structure matches theirs and files are there).

But beyond that, the instructions I posted above aren’t really too hard to follow. You do it once and then you’re done on each machine. It’s been working great for me, I’ve had it up and working on three Macs (iMac + iMac + MBP) at once too.

1 Like

That’s exactly what I had in mind.

1 Like

This worked great. The only side effect seems to be that the “live link” options no longer works. Sites I have not set up to sync work fine.

Any ideas?

Paul

The problem with dropbox it’s the app dont work correctly if you have over 300 000 files ! and wordpress use a lot of files. Me i have project folder, which contain a lot of website test and have over 900 000 files, and now dropbox dont work very good…

@sc0ttkclark Thank you, I think i might get this to work.
I am however stuck on point 14.

1.) Do I move the sites.json file from the original computer or the 2nd computer?
2.) Where to do i move it?
3.) If I have some sites on the second computer that I do not want to sync with `dropbox, will they stay in tact?

Thank you.

@sc0ttkclark One more thing, please:
This is how my remapping looks; is this right?
I deleted the /var and changed log to logs
Thank you very much.

FROM:
/Users/user/Local Sites/beads/logs/php
/var/log/php
TO:
/Users/user/Dropbox/Flywheel/Beads/logs/php
/logs/php

FROM:
/Users/user/Local Sites/beads/app
/app
TO:
/Users/user/Dropbox/Flywheel/Beads/app
/app

FROM:
/Users/user/Local Sites/beads/logs/supervisor
/var/log/supervisor
TO:
/Users/user/Dropbox/Flywheel/Beads/logs/supervisor
/logs/supervisor

FROM:
/Users/user/Local Sites/beads/logs/mysql
/var/log/mysql
TO:
/Users/user/Dropbox/Flywheel/Beads/logs/mysql
/logs/mysql

FROM:
/Users/user/Local Sites/beads/logs/nginx
/var/log/nginx
TO:
/Users/user/Dropbox/Flywheel/Beads/logs/nginx
/logs/nginx

This part was rather obvious, my bad:
Just edited the sites.json, and changed

“path”: “/Users/user/Local Sites/beads”,
to
“path”: “/Users/user/Dropbox/Flywheel/beads”,

BUT, when testing it doesn’t work.

  • Stopped both sites on both computers.
  • Quit LBF on both computers
  • Open LBF on 1st computer and start site
  • Add new post.
  • Stop site
  • Quit LBF
  • Wait for dropbox to finish sync
  • Opened LBF on 2nd computer
  • No changes, no new post…

If I add a plugin on the one computer, it reflects on the other.
But If I activate it, it stay deactivated on the other computer.
So the issue seems to be the path to the SQL that is wrong…

This is what worked for me (a bit simpler list of to-do’s and hopefully helps others):

Computer A:

  1. Install/Setup https://github.com/getflywheel/local-addon-volumes
  2. MUST HAVE THE SITE RUNNING - don’t try remapping volumes when the site isn’t running
  3. Move the app, conf, and logs files from /Users/me/Local Sites/example to /Users/me/Dropbox/local-sites/example.local/
  4. Delete the /Users/me/Local Sites/example/local-site.json file (if exists)
  5. Modify the ~/Library/Application Support/Local by Flywheel/sites.json file with the new site location
  6. Remap the volumes and click the “Remap Volumes” button to restart the site and everything will be good-to-go
  7. Test the site is running on “Computer A”

Computer B:

  1. Install/Setup https://github.com/getflywheel/local-addon-volumes
  2. Create a new site with the same name (e.g. “example.local”) with generic WP install
  3. MUST HAVE THE SITE RUNNING - don’t try remapping volumes when the site isn’t running
  4. Make sure Dropbox is in sync
  5. Follow the same steps for remapping the volumes, restarting the site, and changing the JSON files

Notes:

  • Do not run both Computer A’s site and Computer B’s site at the same times
  • If you Stop on one computer and Start on the other, you may need to fully quit Local by Flywheel
  • For some reason, database is not syncing (feel free to share your ideas how to fix this)
  • You can delete the original /Users/me/Local Sites/example folder or create a symlink or alias and put it there, pointing to the new/actual location
2 Likes

Boom well that was going to my first question how can I sync with dropbox etc so I can work on projects between a desktop and a laptop.

Thank you will follow the guide to set up my first project this way.

Sorry to revive a zombie thread, but has anyone figured out how to do this with Local Lightning? I’d like to be able to work with the same files across machines but with the newer/faster setup!

With Local Lightning you simply make a symlink in the filesystem. Volumes Add-on isn’t really necessary any longer.

1 Like

Yes, but the specific steps you have to take and/or paths you have to symlink are different. This thread started out with step-by-step instructions, so that’s what I’m looking for, in case there are major differences between the old Local By Flywheel and the new Local Lightning under the hood.

And it looks to me like there are big differences. I imported some sites to an iCloud Drive directory on my iMac right before getting a MacBook Pro. Then I used Migration Assistant to set up the laptop. It seemed like both installs of Local were working fine, using the same paths rooted in iCloud Drive, as long as they weren’t running concurrently.

But then I realized the databases were getting out of sync. It seems like Local Lightning doesn’t actually store the raw db data inside the Site path, but rather in ~/Library/Application Support/Local/run/[site-specific ID]. So you may need to copy something in this part of the filesystem onto your cloud storage and them symlink it back to your ~/Library on each computer in order to keep stuff in sync.

I would be interested to know if anyone has worked out the details!

2 Likes

I, too, would be interested in a step-by-step guide to syncing databases between installations of Local 5.1.X, even if it’s not officially supported.

I’ve posted elsewhere how to store Local sites on a shared drive and use the same set of files on each installation. But my method for database syncing is kind of clunky. It involves backing up the database on one installation using a plugin like Updraft Plus and then restoring it to the other.

I was able to make this work with Local Lightening. I find it to be a bit more complex than the previous method (I wish there would be a way to sync sites directly through Local), but for someone who works from a desktop and laptop quite regularly, having my projects in sync is essential.

I’ll probably create a more thorough step-by-step article soon, but here’s how I achieved it:

  1. Create a new website with Local on each computer, ensuring they have identical names and settings.
  2. On your shared server / cloud folder, create a folder with the same website name (this will house the shared files).
  3. Move one website’s app folder to your shared/cloud directory.
  4. In Terminal, type ln -s then drag the app folder from the shared/cloud directory into terminal (this is a quick way to get the path) then drag your local website folder in right after. The command should look something like this: ln -s path/to/shared/app path/to/local/website then press enter (you should see a symlink app folder appear in your local website directory).
  5. Next, locate the database folder by going to the “Database” tab in Local and following the socket path. The folder you want to go to will be a random combination of letters and numbers (right before the mysql folder). This should look something like /Users/Username/Library/Application Support/Local/run/G0xUGB4jj (every site will have a unique letter/number combination).
  6. Go to that folder in the Finder and similarly to before, drag the mysql folder to the cloud/shared directory
  7. Create a symlink from the shared mysql folder to the local directory, which would look something like this: ln -s path/to/shared/mysql Users/Username/Library/Application\ Support/Local/run/G0xUGB4jj (or whatever your folder is called). Press enter and you should see a mysql symlink folder appear.
  8. On your second machine, delete the website’s app folder and locate the database in the same manner and delete its mysql folder as well.
  9. Repeat steps #4 and #7 to create symlinks on your second machine pointing to the shared/cloud app and mysql folders.
  10. Now, both sites should be sharing the same website folder and database. If you make changes on one, they will be reflected on the other (but make sure you never run the sites at the same time or this will cause database conflicts).

Hopefully this helps anyone else that is looking to do the same thing!

2 Likes

Thank you @hellojd! I haven’t tried this yet but I hope to soon. Coronavirus has temporarily rendered the point moot for me. :wink:

For others who are interested in syncing Local sites, I can report that iCloud is probably not the best place to keep them.

The attraction of iCloud (on MacOS) is that I can keep my Local sites in my Documents folder and they’re automatically synced between computers.

The problem is that iCloud suffers some lag when between when files are deleted from your computer and when they’re deleted from the server. In normal file operations, this is not an issue. But when I update a plugin, I often wind up with two copies of all the files in the plugin folder – I see things like “plugin.php” and “plugin-2.php.” The plugin developer didn’t put the second file in there, iCloud did.

Here’s what happens: If the original pre-update files don’t get deleted from iCloud before they’re replaced with the new ones, iCloud tries to sync back the originals from the cloud to your computer. And so you get two copies of the same file.

A workaround for this is to manually update the plugins by deleting the old version of the plugin, checking to see that its folder gone from the iCloud server, and then adding back the new version. But a better solution is probably to use a different cloud service.

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.

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.