How to perform WordPress backups using wp-cli?

I am relatively new to working with WordPress, but I am very comfortable with, and prefer to use the command line. I need to backup WordPress before performing a version upgrade. I came across wp-cli and I assume that it is the go-to utility for working with WordPress on the command line.

When working with WordPress, what do I need to back up, and how can I do this from the command line?

Bonus question: how would you go about automating this to perform regular backups?

1 Answer
1

You can use the WP-CLI command wp db export <filename>

Run the command from within the home directory for the install.

Now, you have a database included in your files. Zip up the directory and move it aside. Now you can perform the upgrade, and if something breaks, replace with the old site and import the old database. voila, previously working site restored.

Leave a Comment