Local by Flywheel

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.

For organizational purposes I install my sites under ~/Local Sites and create a folder that’s synced called Local Sync within my synced directory. 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.

Step 1 — Setting up the primary machine

Start by creating a site in Flywheel. Once your site is up and running, Right click on the site and “Open Site SSH”.

First, backup the database.

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

Next, 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.

Next, add a new map for the database.

Host Source should be the directory you want to sync ~/Sync/Local Sync/site1/sql and the Container Destination will be the following: /var/lib/mysql.

Next, right click on the site and “Open Site SSH” again to remove the current database and copy the backup to the new directory.

rm -rf /var/lib/mysql/*

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

Next. restart the site

Once you verify it’s working correctly you can SSH into the site again and remove the database backup.

rm -rf /mysql-backup

And finally, stop the site

Step 2 — Setting up the secondary machine

Create an identical site on the second machine with the same specs as you did on the primary. Once it’s up and running, follow the same process for setting up the primary machine.

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

Note – Never run these sites simultaneously. When you stop the primary, it will sync the db to all machines to where you can start on the next machine.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.