12 comments

  1. said…

    Hey Shawn!

    Great article. Very nice database transfer example. Just to be clear – STDOUT will be on the local computer where the command is originally executed, right? So production transfers the db to STDOUT locally and then uploads back to staging where it’s imported? So good for smaller websites but for larger databases it would be very bandwidth intensive?

    • said…

      Absolutely Phill. For a large database, I would run this command from the staging server (or whichever environment was the “destination”) in order to avoid the doubling of the bandwidth. This would mean setting up the wp-cli.yml file on either the source or destination server.

      • said…

        Doh. Of course! That makes much more sense than running the wp-cli command in a local dev environment and doubling the bandwidth 🙂

  2. dawninkmsllc said…

    Thanks for this article. We are looking for a replacement for WordShell. We used to use a script WordShell that would let us use something like @all and then loop thru multiple (25+ in our case) WordPress accounts and update each up. Very powerful . I am not familiar with WP-Cli but now that WordShell is coming to its end of life could something like WP-Cli and @all be used to go thru each site, upload and active a plugin?

    • said…

      I’m not familiar with WordShell, so I can’t comment specifically on it. But you could definitely setup a script with WP-CLI that would connect to all your client sites and install/update a plugin! Take a look at the command: wp plugin install –activate. The can be a slug from a plugin in the WordPress.org repo, a zip file path on the site’s server, or a URL to a plugin zip file anywhere on the web.

  3. said…

    Thank you for this tutorial. I’m new to WP-CLI and wonder what else is possible to do with it? Can you move WordPress files from your localhost WP installation to a live website using it, too?

    • said…

      Hey Gavin,

      You’re right! I’ve updated the post to reflect this. Thanks.

  4. peter@pixelliquid.com said…

    Good article. Followed the steps, but the only annoying thing is that I keep getting the error “Cannot connect over SSH using provided configuration”. The first time I got this: “The authenticity of host … … Are you sure you want to continue connecting(yes/no)?” I opted for yes, of course. Then it was just the “Cannot”-error.

    When I login manually I need to type in the passphrase. Where do I put this in the wp-cli.yml file? In the section Aliases there is only place for user, url, path, ssh, http.

    • said…

      I don’t believe you can place your password in the wp-cli.yaml file, which would be extremely insecure anyway. The best bet is to configure passwordless SSH from your computer to your server. Here’s a good article from DigitalOcean explaining how to set that up: https://www.digitalocean.com/community/tutorials/how-to-set-up-ssh-keys–2

      I believe that’s the cause of the “Cannot connect” error you’re receiving.

      • peter@pixelliquid.com said…

        Thanks Shawn I’ll check that article asap. The first time I started using ssh with this provider I created a passphrase so that’s probably the culprit.

Leave a Reply