question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Best way to import WordPress website for development

See original GitHub issue

I really like working on WordPress using 10updocker in my Windows 10 machine as the local environment for WordPress, is very fast compared to other development solutions in windows

I want to know about the best method to import a currently live website for local development using 10updocker.

What I have tried?

  1. Duplicator Plugin
  • Creating a backup package and downloading the file
  • Creating a new environment using 10updocker create
  • After creation deleting all the content of C:\Users\NardDog\wp-local-docker-sites\site-test\wordpress
  • Pasting the package file of duplicator there
  • Visiting site.test/installer.php to start the installation which then extracts the archive of file and imports the database.

Issue : When I reach the step of extraction of archive a 504 error occurs. I was not able to fix this error and complete my Import.

  1. All in one WP Migration
  • Creating a backup file (backup.wpress) and downloading the file into the local system
  • Creating a new environment using 10updocker create
  • Logging in inside the wp-admin and installing All in one WP Migration plugin again
  • Upload the file and restore.

Issue : The restoration for a 1GB backup takes almost 2 hours which is very long time.

Questions

  1. How can I fix the above processes?

  2. Is there any other better and efficient way to do this?

System Specification.

image

image

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
mrmadhatcommented, Jan 5, 2021

The below are the steps I take to transfer an existing live site to wp local docker where the current site doesn’t have any version control / automated way to setup. It doesn’t take long at all once you know the steps, I hope this helps.

Prerequisites

  1. Access to the live sites database
  2. Access to wp-content folder of the site via ssh/sftp
  3. The php version used by the live site
  4. The current table prefix

Step 1: Create a new wp site

Run 10updocker create and answer the prompts

Note: I always use http when inputting the proxy url, I always seem to have problems when mixing non-http/https (If you can’t/don’t want to generate ssl certs because of your setting i.e wsl)

1.b: WSL Users - Update your windows hosts file

When the above command completes you need to update your WINDOWS host file to add the new domain(s)

Open the following file with admin priviledges: c:\Windows\System32\drivers\etc\hosts

Add the hostnames using the following syntax:

127.0.0.1 <hostname> <hostname2>

Step 2: Transfer the live database to the newly created environment

2.a Download the database

Access the database using phpmyadmin or similar and export the tables of your database. Note: make sure you export the tables of the database not the database itself.

Download the backup to your local machine and move it to the folder where the wordpress site is stored. e.g ~/your-local-docker-folder/<site-name>/wordpress

Step 2.b Delete the tables from the LOCAL database of the site you are setting up

# delete the existing tables
10updocker wp db clean

# import the downloaded file
10updocker wp db import <db-backup-file-name>
 

The database should now import successfully however any links to the site in the database will be using the live site url. To fix this you need to do a search and replace on the database to update the urls to match your test site url, to fix this run:

10updocker wp search-replace '<live-url>' '<test-url>'

example:

10updocker wp search-replace 'example.com' 'example.test' 10updocker wp search-replace 'www.example.com' 'example.test'

If your test site is using http rather than https you need to make sure you switch the site url from the https version to the http version

10updocker wp search-replace 'https://example.com' 'http://example.test'

Step3: Transfer themes and plugins

Download the ‘mu-plugins’, ‘plugins’ and ‘themes’ folders from the live site and move them to ~/your-local-docker-folder/<site-name>/wordpress/wp-content folder.

Tip: For speed compress the folders into a backup.zip before downloading then uncompress locally

Step 4: Clean up

To make sure that links work on the site work flush the rewrite rules 10updocker wp rewrite flush  and clear the cache too with 10updocker cache flush

Finish

The live site should now be set up locally.

1reaction
bhanu-krenovatecommented, Dec 3, 2020

I use sage, and during development I use Browsersync and Hot Module Reload which opens the website at http://localhost:3000/.

After every 5-10 mins I keep getting this error :

502 Bad Gateway
nginx/1.13.10

I checked the log of global_gateway_110up/nginx-proxy and this particular log keeps coming in red.


nginx.1 | 2020/12/03 11:03:29 [warn] 64#64: *3809 upstream server temporarily disabled while reading response header from upstream, client: 10.0.0.1, server: example.test, request: "GET /product/okan-saree/ HTTP/1.1", upstream: "http://10.0.128.4:80/product/okan-saree/", host: "example.test"

nginx.1 | 2020/12/03 11:05:01 [error] 64#64: *3839 no live upstreams while connecting to upstream, client: 10.0.128.3, server: example.test, request: "POST /wp-cron.php?doing_wp_cron=1606993501.1179060935974121093750 HTTP/1.1", upstream: "http://example.test/wp-cron.php?doing_wp_cron=1606993501.1179060935974121093750", host: "example.test", referrer: "http://example.test/wp-cron.php?doing_wp_cron=1606993501.1179060935974121093750"

Changed the site name

According to me the container needs more resources because after 2 or 3 refresh the site comes up again.

How can I change configuration to add more resources?

Read more comments on GitHub >

github_iconTop Results From Across the Web

WordPress Migration: 4 Easy Methods and the Best Plugins
Log in to hPanel and go to Website -> Import Website. Under Import your website, select Choose a file to upload the previously...
Read more >
Step-by-Step Guide to Migrate Your WordPress Site to a New ...
Back up your website files; Export The WordPress Database; Create The WordPress Database On Your New Host Server; Edit the wp-config.php File ...
Read more >
How to Do a WordPress Migration on Your Own (With No ...
Export Files using SFTP. The next step is to migrate files from your old site to your new one. This will include theme...
Read more >
Import a Site – WordPress.com Support
Import Everything. Import the content only (pages, posts, and media.) This method can be used on any WordPress.com plan including free sites. ·...
Read more >
How To Migrate WordPress Site To New Host Or Server? [Free]
Migrate Guru is a WordPress plugin built for the express purpose of migrating a site safely from one host to another. It supports...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found