PHP vs Batch file for thesql cronjob

batchcrondatabasePHP

My server details:

OS: Windows Server 2003
IIS6
Plesk 8.xx installed (currently using Plesk to set the cronjob)

I need your advice. I have 2 methods:

Method 1:

Using php + mysqldump, create databases backup files into gzip, and then send email with attachment (each databases has around about 25mb)

Method 2:

Using batch + mysqldump, create databases backup files into gzip, and then send email with attachment (same, each databases has around about 25mb)

My questions:

  1. Whats the difference of using php file and batch file for cronjob?

  2. Which method is better in term of backup speed and send email, and (maybe)safety (e.g., lesser file corrupt occurance)?

  3. If i set the cronjob hourly, will it effect my web performances? I mean, lets say my website has 100++ users online now, and each user making transaction to MySQL, when I perform backup at my web peak hour, will it decrease the performances, like the loading speed, prone to errors etc??

(sorry for my bad english)

P.S: If you need my php and batch file code, please ask me to post it here. I didnt post it now is because, its very simple and standard code.

Best Answer

  1. If you are just doing dumping, gzipping and then sending email, there is no difference. BUT if you are doing more complicated stuffs, using PHP will have advantage, example maybe you want to set timestamps, or parse the output before sending. Then you can make use of PHP's vast libraries and methods for these kind of stuff that batch can't provide (at least easily)

  2. This one you will have to test out yourself.

  3. You might want to set up incremental backup or save just the transactions.(not the whole database)