作者 邓超

备份mysql

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