If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Automatic Table Backup

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-30-04, 11:35
akrishmohan akrishmohan is offline
Registered User
 
Join Date: May 2002
Location: USA
Posts: 9
Automatic Table Backup

Hi Need help in writing a script for automatic table backup everyday at a particular time

I want the contents of the table to be copeid to another table on the same server at a particular time everyday. If a backup copy already exists the script shud check to see if it exists , delete it and then load a fresh copy of the data again.

I know mysqldump does something similar but I jus a want a basic intro and I can go from there

Thanks
-Kri
Reply With Quote
  #2 (permalink)  
Old 07-03-04, 20:07
yellowmarker yellowmarker is offline
Registered User
 
Join Date: Jul 2004
Location: Dundee, Scotland
Posts: 107
-> so if you are using Linux you'll be using cron to run a script at a certain time each day. you are unlikley to call a PHP script. you are likely to run a script which logs into the MySQL database and then runs a few queries.

re "If a backup copy already exists the script shud check to see if it exists , delete it and then load a fresh copy of the data again."
-> For example, use:
DROP TABLE IF EXISTS `database_name`.`backup_table_name` ;

CREATE TABLE `database_name`.`backup_table_name` (
`received` date NOT NULL default '0000-00-00',
`replied` date NOT NULL default '0000-00-00'
) TYPE = MYISAM ;

INSERT INTO `database_name`.`backup_table_name`
SELECT *
FROM `database_name`.`live_table_name` ;


note: depending on your needs you might prefer to clear the data in the backup table using the following "truncate" statement instead of dropping and re-creating the backup table:
TRUNCATE TABLE `temp2`;
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 On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On