- Create a new WordPress site.
- Export the database of old site in /wp-content/
wp db export wp-content/database.sql
- Navigate to the new site “root”.
cd <path-to-new-site>
- Copy files of the old site to new site directory.
rsync -av --delete --exclude=.git/ --exclude=wp-config.php <path-to-old-site> <path-to-new-site>
-a = Copies all the files from source to destination recursively it also compresses the files when copying so less bandwidth is used.
-v = Verbose, Displays all the files that are being copied.–delete = delete’s the extra files present on the new site so that all the files/folders are exactly same as the old site.
–exclude = Exclude files/folders when copying.NOTE – After this process make sure the wp-config.php file is not copied over, the new site should have it’s same file.
- In the new site drop the current database and import the database in wp-content directory (this databse was copied from old site in step 4)
wp db drop
– drop the current database
wp db create
– create the database using the wp-config file.
wp db import wp-content/database.sql
– Import the database copied from the old site.
- If the site is multisite, copy the extra Multisite constants from the old site to new site.
- Search Replace the old URLs to new URLs
wp searh-replace <old-url> <new-url> --precise --recurse-objects
If the site is a multisite –
wp --url=<old-site> searh-replace <old-url> <new-url> --precise --recurse-objects --network
- IF any cache is used on teh site clear it.
wp beaver clearcache
– Clear the beaver builder cache.
wp nnginx-helper purge-all
– Clear nginx helper cache.