Development with Local by Flywheel on Multiple Machines

I recently switched from Vagrant (VVV) to Local by Flywheel. There are a few reasons for the switch but without making the post about that, Local is just easier and doesn’t have as many dependencies.

Previously I wrote a post about how to sync VVV across multiple machines so I wanted to figure out a way to do this with Local. In this post I’ll show you how to sync Machine 1 and Machine 2 but just repeat the process and you can sync as many as you’d like.

Prerequisites

  • Local installed on all machines
  • Volumes add-on for Local
  • Syncing software such as Resilio Sync, Dropbox, Google Drive, etc

For organizational purposes I install my sites under ~/Local Sites and create a folder that’s synced called Local Sync. For this post we’ll define “Sync” as the root of your syncing directory of choice.

For file syncing I use and strongly suggest Resilio Sync but you can use Dropbox or whatever flavor you want.

Here’s what the directory structure will look like:

Machine 1

  • ~/Local Sites
    • site1
    • site2

Machine 2

  • ~/Local Sites
    • site1
    • site2

Synced Directory

Will contain WordPress itself and backups of the database.

  • ~/Sync/Local Sync
    • site-1
      • app
      • sql
    • site-2
      • app
      • sql

Machine 1

Create site-1

Right click on the site and “Open Site SSH”

Backup the current db

cp -r /var/lib/mysql /mysql-backup

Under the More > Volumes tab change the Host Source for /app to a directory in your synced folder and move the contents of /Local Sites/app to /Sync/Local Sync/site1/app

Add a new map

Host Source ~/Sync/Local Sync/site1/sql

Container Destination /var/lib/mysql

Right click on the site and “Open Site SSH”

rm -rf /var/lib/mysql/*

cp -r /mysql-backup/* /var/lib/mysql

Restart the site

Once you verify it’s working right you can SSH in again and rm -rf /mysql-backup to remove that folder

Stop the site

Save as Blueprint

Copy the Blueprint to Machine 2 (located in ~/Library/Application Support/Local by Flywheel/blueprints)

Machine 2

Import the Blueprint and setup the site as usual

Under the More > Volumes tab update /app and /var/lib/mysql destination just like above

Restart site

Machine 2 will now be running site from Machine 1

Important note: Never run these sites simultaneously. When you stop Machine 1, it will sync the db to all machines to where you can start on the next machine.

Leave a Reply