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
-> 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`
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`;