Using Dropbox to sync Local sites between computers under Local Classic

I setup my Dropbox to sync between my computers so I can ensure I’m always able to pick up where I left off when developing locally, even when work is not yet committed. More importantly, I can very easily roll back changes/deleted files since I use Dropbox’ packrat feature.

Here’s how to get it setup:

  1. Start with Local setup with the sites on one computer, store the sites you want to share inside a Dropbox folder
  2. Export each site to blueprints
  3. Move blueprints from ~/Library/Application Support/Local by Flywheel/blueprints to the other computer
  4. Install Local on other computer
  5. Import blueprints but use a different folder outside of the Dropbox folder, this is temporary
  6. Sites will provision and get setup in Docker
  7. Now we can change the paths easily enough
  8. Checkout/clone the Local Add-on repo for Volumes - https://github.com/getflywheel/local-addon-volumes to the ~/Library/Application Support/Local by Flywheel/addons/local-addon-volumes folder
  9. Enable the add-on ‘Volumes Manager’ then restart Local
  10. Go into each site that you want to be based in the Dropbox folder and start them
  11. Go to the More > Volumes section of the site info
  12. Adjust the directory path easily by changing the values on the left side, then click ‘Remap Volumes’
  13. Local will provision the updated mappings
  14. After doing this for all of the sites you want to move/change, edit the ~/Library/Application Support/Local by Flywheel/sites.json file and adjust the ‘path’ strings there too.

Now you’ve got Dropbox shared Local sites, which shares the files and server configs/logs.

9 Likes

FYI, same method works for any file syncing method, if you’re using Google Drive or whatever. Goal is to ultimately get Local to change the path to the synced directories.

A post was split to a new topic: Local Router cannot connect to site

Sorry, unable to help you since I didn’t run into that. I would suggest opening a new topic, linking to this one saying you followed the steps, and posting your exact error.

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!

3 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.