restore mysql DB every hour

This is a discussion on restore mysql DB every hour within the MySQL Database forums, part of the Database Forums category; I have a CMS driven website that uses MySQL as is database. I want to create a demo site that ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-05-2008
CNN_news
 
Posts: n/a
Default restore mysql DB every hour

I have a CMS driven website that uses MySQL as is database.

I want to create a demo site that anyone can edit but that resets its
contents every hour so changes are not permanent.

How can I do this?

Thanks.
Reply With Quote
  #2 (permalink)  
Old 03-05-2008
Jerry Stuckle
 
Posts: n/a
Default Re: restore mysql DB every hour

CNN_news wrote:
> I have a CMS driven website that uses MySQL as is database.
>
> I want to create a demo site that anyone can edit but that resets its
> contents every hour so changes are not permanent.
>
> How can I do this?
>
> Thanks.
>


Build the database to the point where you want it restored. Back it up
and create a cron job to restore it once an hour.

BTW, I recommend stopping MySQL while the restore is being performed.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Reply With Quote
  #3 (permalink)  
Old 03-05-2008
superfly
 
Posts: n/a
Default Re: restore mysql DB every hour

On Mar 5, 2:04*am, CNN_news <Nagit...@gmail.com> wrote:
> I have a CMS driven website that uses MySQL as is database.
>
> I want to create a demo site that anyone can edit but that resets its
> contents every hour so changes are not permanent.
>
> How can I do this?
>
> Thanks.


try taking a snapshop of your database / tables using mysqldump then
restore using cron task every hour or whenever you want to restore the
data.

check out http://dev.mysql.com/doc/refman/5.0/en/mysqldump.html


Reply With Quote
  #4 (permalink)  
Old 03-06-2008
John Nagle
 
Posts: n/a
Default Re: restore mysql DB every hour

Jerry Stuckle wrote:
> CNN_news wrote:
>> I have a CMS driven website that uses MySQL as is database.
>>
>> I want to create a demo site that anyone can edit but that resets its
>> contents every hour so changes are not permanent.
>>
>> How can I do this?
>>
>> Thanks.
>>

>
> Build the database to the point where you want it restored. Back it up
> and create a cron job to restore it once an hour.
>
> BTW, I recommend stopping MySQL while the restore is being performed.


Nah. Make up tables that represent the database in the desired initial
state. Then, every hour, make new copies of those tables. Then use
ALTER TABLE with RENAME to rename the current tables to "old" versions,
and the new copies to the current tables. Then delete the old versions.

Multiple renames done in one ALTER TABLE are atomic, so you can do this
with activity in the database. It's all interlocked and you don't have to
shut down.

Or make all the databases InnoDB databases, and in one transaction,
set them back to the desired ground state. When you commit the transaction,
all the changes happen as an atomic operation, without interfering with
anything in progress.

John Nagle
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 08:29 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0