windows 7 - php mysqldump and zip 7z -
i have line of php backing databases, work's charm (windows 7):
$exec_str = "{$real_path}bin\mysqldump -h {$mysql_db_host} -u {$mysql_db_user} -p{$mysql_db_pasw} {$db_name} > {$backupdir}\\{$db_name}.sql";
but rather prefer have .sql files compressed 7zip (as 7z)
this 1 not work (path 7za.exe correct) instead generates empty 7z files:
$exec_str = "{$real_path}bin\mysqldump -h {$mysql_db_host} -u {$mysql_db_user} -p{$mysql_db_pasw} {$db_name} | {$real_path}7za > {$backupdir}\\{$db_name}.sql.7z";
what doing wrong?
i used 7z compress output mysqldump (windows server 2008 r2), used command line batch files , automated tasks instead. also, used 7z.exe, not 7za.
note following commands executed windows command terminal, i.e start->run->cmd
i created batch file automated task run contents:
mysqldump -u<mysqlusername> -p<mysqlpassword> <schemaname>|7z.exe -si<nameinzip> <zippedpathandname.7z>
this creates .7z file of mysqldump. [-si] switch specifies take input stdin. "nameinzip" want appear in zip file; made mine "schemaname".sql.
note: assumes mysqldump , 7z executable directories in %path% environment variable. otherwise use full path binaries, e.g. c:\program files\7-zip\7z.exe instead of 7z.exe
then created automated task:
schtasks /create /sc daily /tn <yourtaskname> /ru system /tr <pathtoyourbatchfile> /st 20:45
this creates automated task runs batch file daily @ 20:45. note "/ru system" switch ensures command run system , run whether you're logged on or not.
see here reference schtasks command.
hope helps!
Comments
Post a Comment