Create Local Installation from Flywheel Backup Zip with WP-CLI

In the WordPress performance world we often have to debug speed issues. Hosts like Flywheel provide an easy way to generate a zipped backup file with the site and database so you can make a local copy. This tutorial will show you how to generate the Flywheel backup and prepare a local copy by unpacking the files and importing the database.

First we need to generate the backup zip of the WordPress site or WooCommerce store on Flywheel.

Once it finishes you will get an email from Flywheel with the download link. You will need to right click on the DOWNLOAD button and copy the link address to get the download link.

Now SSH into your server and go to a temporary directory

cd /tmp
wget "<download-link>" -O flywheelbackup.zip

Now enter your local installation folder

cd /var/www/sitename
unzip -q /tmp/flywheelbackup.zip

You will see a files folder and mysql.sql database dump

mv files/ ./
rm -rf files

Since Flywheel’s backup doesn’t include the WordPress core files you will need to download them

wp core download --allow-root

If you need to download a specific WordPress core version then you can use the --version flag

wp core download --version=4.9.1 --allow-root

Now we need to create a wp-config.php and enter the database credentials you have on the server for this local copy of the site.

wp config create --prompt --allow-root

Fill in the prompts

1/12 --dbname=: wpbulletdemo
2/12 --dbuser=: wpbulletdemo
3/12 [--dbpass=]: passw0rd
4/12 [--dbhost=]: localhost
5/12 [--dbprefix=]:
6/12 [--dbcharset=]:
7/12 [--dbcollate=]:
8/12 [--locale=]:
9/12 [--extra-php] (Y/n): n
10/12 [--skip-salts] (Y/n): n
11/12 [--skip-check] (Y/n): n
12/12 [--force] (Y/n): Y
Success: Generated 'wp-config.php' file.

Now we can import the database dump with WP-CLI

wp db import /tmp/backup.sql --allow-root

You can also do a search and replace for the live domain (live-domain) to your local domain (local-domain)

wp search-replace "live-domain" "local-domain" --all-tables --allow-root

It is also a good idea to set the Discourage Search Engines option on

wp option update blog_public 0 --allow-root

Make sure to reset any permissions in case you used the root user 😉