0

I want to run a cron which will take back up of data of a particular table for last three months and then it will delete the data which has been saved to the backup file. I have not done this before. Can I have some guidelines how to accomplish it ?

I have studied how to set cron, but confused with the backup process.

My project is in Kohana 3.0.7 and uses Mysql.

hakre
  • 193,403
  • 52
  • 435
  • 836
KutePHP
  • 2,206
  • 6
  • 36
  • 54

1 Answers1

0

You could either point your cron at a php script on the server and do whatever you need to do from there.

OR

Directly from the cron script itself you could use the mysql client commands as follows (not tested!):

0 0 * * * mysqldump -t -u[username] -p[password] dbname table_name --where="date_field>xyz" > /home/username/data.sql
0 0 * * * mysql -u[username] -p[password] dbname -e 'delete from...'
Niall
  • 425
  • 6
  • 14