Best way to move live site local

Why didn’t you try to copy your live website manually. It’s not as easy as using a plugin but much more error proof. You will need to follow these steps.

  1. Make a dump of MYSQL database on server.

    mysqldump -u username -p -h localhost dbname > domain.sql
    
  2. Create a archive of your WordPress website on server.

    tar -czf domain.tar.gz domain.com
    
  3. Download both on local machine. And extract the archive.

    tar -xzf domain.tar.gz
    
  4. Import database at local machine.

    mysql -u username -p -h localhost dbname < domain.sql
    
  5. Now change wp-config.php values for local server.

  6. Change domain name in MySQL. You can run these mysql queries to replace it with local domain setup.

    UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldurl.com', 'http://www.newurl.com') WHERE option_name="home" OR option_name="siteurl";
    UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl.com','http://www.newurl.com');
    UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldurl.com', 'http://www.newurl.com');
    UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.oldurl.com','http://www.newurl.com');
    

Or simply define these in wp-config.php, these will overwrite domain URLs in database. I think this will be better for local development.

define( 'WP_HOME', 'http://example.com/blog' );
define( 'WP_SITEURL', 'http://example.com/blog' );
  1. Done.

I develop and move nearly 7-10 WordPress websites each month and this is what I do. I can’t say it’s better than using a plugin or any other migration tool but it’s more controlled. And once you get familiar with the process, there are very less chances of error.

Leave a Comment