作者 邓超

备份mysql

... ... @@ -9,13 +9,13 @@ if(!is_dir($dir)){
}
$tables = db()->query("show tables;")->fetchAll();
_echo("开始备份mysql数据");
foreach ($tables as $table){
$table = array_values($table)[0];
$name = $dir.$table.".create.sql";
_echo("正在备份表结构 ".$table);
echo "正在备份表结构 ".$table."\n";
// 显示表结构
$c = db()->query("show create table {$table}")->fetch();
... ... @@ -29,7 +29,7 @@ foreach ($tables as $table){
$p = 0;
$limit = 1000;
while (1){
echo "当前备份 $p\r";
echo "正在备份数据 当前 $p\r";
$lists = db()->all("select * from `{$table}` limit {$limit} offset ".($p*$limit));
if($lists){
foreach ($lists as $list)
... ...