What is the most efficient way to reset a WordPress site?

I occasionally want to reset my WordPress installation back to default--both the database and files. What is the most efficient way to do so?

I know there are viable plugins to reset the database. But are there automated methods to reset the files to default as well? Or do I need to simply delete everything and re-upload all the WordPress files?

Topic workflow database Wordpress

Category Web


If you only want to empty the site of its content (posts, comments, terms, and meta) then there's a wp-cli command for that:

$ wp site empty

Use the the --uploads parameter to delete all files in the uploads folder and --yes to skip the conformation.

Warning: Remember to backup before testing!

See the wp-cli docs for more information:


You can use git and a script:

#!/bin/bash
# check out a revision
git checkout master

# Force-add the wordpress config to the index so it
# isn't removed in the next step (add any other
# .gitignore'd files you want to keep to the end of
# this)
git add -f config/wp-config.php  

# remove any files/directories not in the index
git clean -fdx

# removes files added to index in step 2 from the
# index (but doesn't remove them from the disk)
git reset

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.