-
Notifications
You must be signed in to change notification settings - Fork 0
/
dump.php
53 lines (50 loc) · 1.09 KB
/
dump.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
48
49
50
51
52
53
<?php
## Configuration
$db = '';
$user = '';
$pass = '';
$host = '';
$utf8 = false;
$nohup = true;
$gzip = true;
$file = 'dump-'.$db.'-'.date('Ymd_His').'.sql';
## Dump Logic
if (!empty($_POST)) {
foreach (glob('*.sql*') as $file) {
$file = basename($file);
echo '<a href="'.$file.'">'.$file.'</a> - '.round(filesize($file)/1024,2).'kB<br>';
}
die();
}
echo '<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>';
$script = <<<JQUERY
<script type="text/javascript">
jQuery(document).ready(function(){
setInterval(function(){
jQuery.post('?',{ sizes: 1 }, function(data){
jQuery('#response').html(data);
});
}, 500);
});
</script>
JQUERY;
echo $script;
echo '<pre>';
$dump = '';
if ($nohup == 1) {
$dump .= 'nohup ';
}
$dump = 'mysqldump --user '.$user.' -p'.$pass.' '.$db
.' --host='.$host.' --dump-date=false ';
if (!$utf8) {
$dump .= '--default-character-set=latin1 ';
}
if ($gzip) {
$file .= '.gz';
$dump .= '| gzip ';
}
$dump .= '> '.$file.' 2>&1 &';
system($dump);
echo '<div id="response"></div>';
echo '</pre>';
?>