ideas on how to reload demo site db daily [closed]
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this questionI have a demo site where users can log into the site and change pretty much everything, including the page with the instructions on how to log in :)
obviously i cant leave this site up without rebuilding its database now and then, or ill be linking to goatse before i know it.
i am open to ideas on the easiest way to do this.
I am running grails which uses hibernate behind the scenes. i wonder if a proc to drop a开发者_如何学Goll the tables, and reinsert data will make hibernate throw up.
another option would be to run a quartz job to programatically remove everything and reinsert it, but the problem with that is that its MUCH easier to setup the initial version via the sites admin interface, so id be doing a lot of work via services
Assuming your using MySQL set up a job using your operating system's scheduling facilities
to run the mysql client with an sql dump of the state you want to bring the database to every day. I've done this on a grails app and had no problems although your users may run into issues if they try and access the site while the database is being restored. When I've recreated the database from a dump while my grails app was running I had no issues accessing it after the database restore. If your not using mysql the same instructions should apply, you'll just have to use a method specific to your database. When I did this I did not drop and create the actual database, I just dropped and recreated all the database tables.
DBUnit - http://dbunit.sourceforge.net/
As your site is in effect a "Test" site, and you want it to revert back to a well known state, it may be the right answer for you.
精彩评论