二、让MYSQL实现自动备份变成可能!
1、编辑如下代码,并保存为backup.php,如果要压缩可以拷贝一个rar.exe:
<?php
if ($argc != 2 || in_array($argv[1], array('--help', '-?'))) {
?>
backup Ver 0.01, for Win95/Win98/WinNT/Win2000/WinXP on i32
Copyright (C) 2000 ptker All rights reserved.
This is free software,and you are welcome to modify and redistribute it
under the GPL license
PHP Shell script for the backup MySQL database.
Usage: <?php echo $argv[0]; ?> <option>
<option> can be database name you would like to backup.
With the --help, or -? options, you can get this help and exit.
<?php
} else {
$dbname = $argv[1];
$dump_tool = "c:\\mysql\\bin\\mysqldump";
$rar_tool = "d:\\php4\\rar";
@exec("$dump_tool --opt -u user -ppassword $dbname > ./$dbname.sql");
@exec("$rar_tool a -ag_yyyy_mm_dd_hh_mm $dbname.rar $dbname.sql");
@unlink("$dbname.sql");
echo "Backup complete!";
}
?>