I am in the process of creating a Drupal demo and am considering having the database reloaded automatically every 12-24 hours. This would result changes made by the demo user and restore the site to the original configuration (thus minimizing any vandalism). I could do this manually but having a cron that automatically does this would be better. Any links to tutorials or advice on how to do this would be appreciated. Thanks!

Joshua

Comments

TomChiverton’s picture

You'll need to use whatever your database provides in terms of backup/restore.

On MySQL, you'd use mysqldump to backup the DB to a file when the site was 'clean', then "mysql < filename.sql" to reload all the tables in a cron job.

Acert93’s picture

Thanks Tom.

I should have clarified that I am using MySQL 4.0, PHP 4.3, and Drupal 4.7.

TomChiverton’s picture

Well, there you go then :-)

Acert93’s picture

mysql -u drupaldbusername -p******** drupaldbname < /home/drupaltest/public_html/backup/drupaldb.sql

For future reference for others:

1. By your method of choice (I used PHPMyAdmin) backup your database and make sure you select the option "Add DROP TABLE"

2. From the commandline run your database. Below is a template of the command (remove the brackets and put your specific information in):

mysql -u [database_username] -p[database_user_password] [database_name] < [/path/to/your/backup/database/dbname.sql

An example:

Database Name: drupal
Database Username: acert93
DB User Password: testing
Backup database: backup_drupal.sql
Path to database: /home/demonstration/www/backup/

mysql -u acert93 -ptesting drupal < /home/demonstration/www/backup/backup_drupal.sql

And if you want to run this at a set interval use a cron... now to go learn and fight cron timing! :)