Guides › WordPress › Backups & restore

WP-CLI Search-Replace to Change Domain or URLs Safely

The search-replace command handles serialized data correctly. Always run a dry run first.

Reference guide. This guide is written from established practice and the official documentation of the tools involved. We have not yet tested every step on a live demo site. Back up your site before you change anything.
Backups and restore

Why use it

Plain text replace breaks serialized data. WP-CLI understands it.

Steps

  1. Back up the database. See WordPress backups.
  2. Dry run: wp search-replace 'http://old.example' 'https://new.example' --dry-run.
  3. Read the counts per table.
  4. Run it without --dry-run.
  5. Flush caches and save permalinks.

Tips

See moving a WordPress site.

Related guides

Did this solve it? If not, email hello@sitefixlab.org with the exact error text and we will look into it. Try the problem finder.

Last updated 2026-11-21.