Shawn Hooper’s got a great new article up about running WP-CLI commands on a remote server. At first, based on his title, I worried the answer was “there’s this thing called SSH…” But my worry was unnecessary. This is not an article about the hot technology of SSH, or at least not exclusively. (I really shouldn’t have worried me. I’ve seen Shawn give talks, and he’s no slouch on the expertise side.)
Anyway, what I didn’t know is that there is a pretty cool facility right within WP-CLI to let it itself do the SSHing for you. So if you set up the neat little aliasing system that Shawn outlines you actually have no need to ever type SSH addresses yourself.
But if you follow along though Shawn’s steps, a DB-only migration with WP-CLI can look like this:
wp @production search-replace example.com staging.example.com --export | wp @staging db import -
I actually published a Quick Guide about WP-CLI enabled site migrations a few months ago. It handles the file-side of migrating, but it does lack the concision of Shawn’s solution.
This some next-level WP-CLI-fu. Anyway, if this is useful for you definitely check out the link for exactly how to get set up. It does require that you have WP-CLI on both ends, but beyond that it’s a pretty simple process. I didn’t know about the YAML configuration of WP-CLI, but it’s really the heart of the magic here.
Image credit: Wkimedia