Run your WordPress site locally using the Updraft Migrator

April 4, 2021
Cristian Sánchez

In this blog post, we explain how you can run a WordPress site locally using the Updraft Plus Migrator tool in a few easy steps. Running your WordPress site locally can be very useful for testing features and changes to your site’s code that may break things. You will be free to break it without much worry and with this method, you will be able to create a new instance of your site very quickly if anything goes wrong.

Requirements for following this tutorial

The following are requirements to follow this tutorial. Each item has a link to make sure you can meet the requirements.

Docker Desktop installed on your computer. You can download Docker desktop for Windows here.

UpdraftPlus plugin and the UpdraftPlus migrator tool activated on your site. The migrator tool is a paid extension of Updraft Plus.  You can see more information here. The migrator tool can be activated for unlimited sites.

Step 1: Create a backup of your website using Updraft Plus and send it to Dropbox (or another preferred storage)

First, we need to create a backup of the website using Updraft Plus and send it to your preferred cloud storage solution that is available to use with Updraft Plus. To set up the export, go to the Updraft Plus backup settings and set up the remote storage option as shown in Figure 1. Because I had space available in Dropbox, I used that. Furthermore, Dropbox can be used with the free version of Updraft plus. I also had free space available to be used for this.

Updraft plus will ask you to set up the connection with your cloud storage. Then, follow the steps shown by Updraft to connect your cloud storage to the tool.

Step 2: Create a local docker container with WordPress installed

After securing your site backup, create a new folder for your docker instance.

Then, open your Notepad and create a new file named docker-compose.yml with the following code:

version: "3.9"
    image: mysql:5.7
      - db_data:/var/lib/mysql
    restart: always
      MYSQL_ROOT_PASSWORD: somewordpress
      MYSQL_DATABASE: wordpress
      MYSQL_USER: wordpress
      MYSQL_PASSWORD: wordpress
      - db
    image: wordpress:latest
      - "8000:80"
    restart: always
      WORDPRESS_DB_HOST: db:3306
      WORDPRESS_DB_USER: wordpress
      WORDPRESS_DB_PASSWORD: wordpress
      WORDPRESS_DB_NAME: wordpress
  db_data: {}

Change the credentials in the yml as desired, however, the credentials will be overwritten by the import later.

Open a terminal window and change to the directory you created.

Run the following command:

docker-compose up -d

In Docker desktop, you should be able to see a new container running which will have the same name as the folder in which you ran docker-compose up.

Click on the option to open the wordpress instance in the browser as shown in the following figure.

You should see the wordpress start page:

Set up your initial site info, but don’t worry about it because it will be overwritten when you import your site.

Step 3: Update the local WordPress .htaccess file to increase max upload size

Now that you have access to the WordPress dashboard we need to change some settings in the WordPress installation to be able to upload our UpdraftPlus extended or premium plugin. This is because the default max upload size is 2mb.

To increase the max upload size, we need to modify the .htaccess file. Access the docker terminal by clicking on the button shown in the following image:

Enter the following command:

cat .htaccess

That will show the current htaccess file. My initial .htaccess file looks like this:

This means that I need to add new lines after line 5. However, your WordPress installation may have a different .htaccess file so please check before running the following command and modify it as needed. I ran the following command:

sed -i "6i php_value upload_max_filesize 256M" .htaccess && sed -i "7i php_value post_max_size 256M" .htaccess

This command adds the lines  “php_value upload_max_filesize 256M” and “php_value post_max_size 256M” to lines 6 and 7.

Step 4: Install the UpdraftPlus plugin and run your WordPress site locally

After that you can install the UpdraftPlus premium plugin:

Go to the UpdraftPlus plugin page, to the Premium tab and connect your Updraft account. Then activate the “Migrate a WordPress site to a different location” feature. This feature supports unlimited sites, so it will not affect your number of installs.

After that, you are ready to migrate your site’s backup to your local docker instance. Go to the backup/restore tab. In the existing backups area, click on Upload Backup Files then click on select files or drag and drop the backup files.

Now go to the Migrate/clone tab. In the migrate area, click on “Restore an existing backup onto this site”.

Click Restore and then select the desired restore options:

If you have activated Database encryption with Updraft premium, then you need to activate Updraft premium to unencrypt your database during the migration.

Click next to continue the process. And eventually you will see a success message:

After the import you should be able to see your site’s home page! Now you can run your WordPress site locally and it is now ready for testing.

Feel free to leave a comment down below if you get stuck or have any questions or comments about this setup. If you found this tutorial useful, like us on Facebook for more updates and tutorials like this. If you are interested in our web development services, contact us. At CSV Code, we code so you don’t have to.

Leave a Reply

Your email address will not be published. Required fields are marked *