-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrdbsync.php
47 lines (40 loc) · 1.01 KB
/
rdbsync.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
function mysql_run($command)
{
$params = array(
':host' => $_GET['host'],
':username' => $_GET['username'],
':password' => $_GET['password'],
':name' => $_GET['name'],
':dump_filename' => 'rdbsync.sql',
);
//$backup_file = 'rsbsync' . date("Y-m-d-H-i-s");
$command = strtr($command, $params);
$result = array(
'exit_status' => null,
'output' => null,
'command' => $command,
);
try {
exec($command, $output, $exit_status);
$result['exit_status'] = $exit_status;
$result['output'] = $output;
} catch (Exception $e) {
$result['output'] = $e->getMessage();
}
print(json_encode($result));
}
function remote_export(){
mysql_run("(mysqldump -h :host -u :username -p':password' :name > :dump_filename) 2>&1");
}
function remote_import(){
mysql_run("mysql -h :host -u :username -p':password' :name < :dump_filename");
}
switch ($_GET['action']) {
case "remote_import":
remote_import();
break;
case "remote_export":
remote_export();
break;
}