Reset WordPress website

One way to solve this would be to set up your demo site exactly how you want it to reset every day (use a standard username and pass like “admin” and “testpass”), and then dump the database and zip the files. Then, put the zip somewhere on your server. Set up a BASH script that deletes the contents of the current WordPress directory, drops all the tables from the database, copies the zip file in, unzips it, and then imports the database file to the db. Then, you can set up a cron to run the file every night at midnight. Here’s some info on how to set up a cron:

http://www.cyberciti.biz/faq/how-do-i-add-jobs-to-cron-under-linux-or-unix-oses/

Give me a bit and I’ll whip up a code example.

EDIT:

Once you have your files zipped, you can write a BASH script like this:

#!/bin/bash

rm -rf ~/path/to/your-website/*
mysql -u your-db-username -pyour-db-password -e "DROP DATABASE wordpress_database"
cp ~/path/to/your.zip ~/path/to/your-website
unzip ~/path/to/your-website/your.zip
mysql -u your-db-username -pyour-db-password -e "CREATE DATABASE wordpress_database"
mysql -u your-db-username -pyour-db-password wordpress_database < ~/path/to/your-website/db-dump.sql

Something like that should get the job done. Just put this into a file like “reset-test-site.sh”, and set up a cron to run the script every night at midnight.

Also, note the lack of a space in the mysql command between the “-p” option and the actual password. This is NOT a typo, and is the way this command works. Just wanted to make sure you know this isn’t an error.