Local Beta on Multiple Computers

@ben.turner has suggested that in Local 5.X it should be easier to store a site in a shared folder. Using a shared folder for your sites is attractive because it could make it easier to continue development on a site while traveling.

I’ve performed an initial test of this idea and it appears to work. Here’s what I did:

  1. Create a site in a shared folder (I’m using iCloud) on computer A
  2. Wait for iCloud to sync and then hide that folder somewhere. (The reason for hiding the folder is that Local will not allow you to overwrite an existing site when creating a new one. You could even delete the folder. You won’t need it after step 3.)
  3. Create a site on computer B with the same name, in exactly the same location as the site from computer A
  4. Wait for iCloud to sync between computers
  5. I am now able to load the site on either computer A or B.

Whatever changes you make to the theme files on computer A will automatically appear on computer B, since both sites are sharing the same files. But any database changes will need to be synced some other way.

My method is to use Updraft Plus to backup the database from computer A and then restore it on computer B. But perhaps someone else can think of a more elegant solution. The problem with my method is that if I forget to backup on computer A before I move to computer B then I won’t have an updated version of the database. I’d have to reimport from the database dump when the site on computer A was stopped.

1 Like

So cool! Stopping a site dumps its database to /app/sql. This could sync across machines? You’d have to manually import the DB each time you switch computers though.
If Local offered a Workstation Sync service, what features would you want included? :wink:

A Local development site that syncs across computers begins to blur the distinction between a live site and a development site, so in your documentation you’d want to be clear about what it is and what it isn’t. Users would need to understand that the site must be located on a shared drive (i.e., iCloud, Dropbox, Google Drive, or private file server) but that it is not the equivalent of a hosted site on a remote server. It’s simply a way of syncing a development site so that you can work on it in two different installations of Local, on two different computers.

To make this feature user-friendly in an officially supported version, perhaps you could do something like this:

  1. Implement a “shared-mode” for Local sites, which can be enabled for particular sites by a checkbox or sliding switch in Local.
  2. Shared mode sites are distinguished by the fact that they read in the database from the database dump each time they are started.
  3. To prevent conflicts resulting from the database being edited on two different computers, shared-mode sites can only be open on one computer at a time. A site’s status (whether open or closed) could be indicated in a file in the site folder that is read and edited by Local when the site is started and then edited again when the site is stopped). If the site is already open somewhere else, Local throws up a warning dialog instructing the user to close the site on the other computer first.
  4. Finally, create an option to import an existing site in shared mode. This import creates no new site files (they already exist on the shared drive) but simply creates a database attached to the existing site files and imports the database dump into the database.
  5. Shared sites might be indicated in Local simply as “MY SITE (shared)”

So, the user-experience might be as simple as this:

  1. User creates a site in Local on computer A.
  2. User designates the site as a shared site, either at creation or at a later time.
  3. User imports the shared site in Local on computer B.
  4. User can now work on the site on ether computer, the only restrictions being that it is not possible to work on both computers at once, and that the site will start up a little more slowly because the database has to be read in each time.

I think this would be a very attractive feature for anyone who splits development time between work and home computers, or between a desktop and a laptop.

1 Like

Update: Another way to import the database

Sharing a Local site between installations of Local as I have described above doesn’t sync the databases. The installations use the same set of files, but each installation retains it’s own database.

I had previously been using a plugin (UpdraftPlus) to import the database from a backup generated by one installation into the other. But it turns out that it’s also possible to read in the database dump directly using Sequel Pro. Local creates a database dump each time the site is stopped. We can import the dump into a site on another installation of Local.

The process is as follows:

  1. In Local, open Sequel Pro for the site you into which you want to import the database
  2. Navigate to “site/app/sql” and select the most recent database dump
  3. Import the database and you’re good to go

Some users might find this method easier than my previous method because it doesn’t depend on a backup plugin.

1 Like