Thursday, December 30, 2010

Perl scripts to automate MySQL Backup

it requires simple modifications like Folder Path Details / user & database details and we can schedule this on need basis.

#!/usr/bin/perl
($Second, $Minute, $Hour, $Day, $Month, $Year, $WeekDay, $DayOfYear, $IsDST) = localtime(time) ;

$Year += 1900 ; $Month += 1;

$dt = sprintf("%02d-%02d-%04d-%02d-%02d-%02d",$Day , $Month, $Year, $Hour, $Minute, $Second,) ;

exec "mysqldump -u UserName -pPassword DatabaseName | gzip > FilePath\\$dt.gz";

Click to Download

No comments:

Post a Comment