-
Notifications
You must be signed in to change notification settings - Fork 0
/
backup.php
21 lines (15 loc) · 922 Bytes
/
backup.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php
include_once "db.php"; // connect to the database
$session_id = $db->query("SELECT max(session_id) AS max_id from t_session_val")->fetch();
//$filename = "backup-" . date("d-m-Y") . ".sql.gz";
//$mime = "application/x-gzip";
$filename = "backup-" . date("d-m-Y") . ".sql";
$mime = "application/text";
header( "Content-Type: " . $mime );
header( 'Content-Disposition: attachment; filename="' . $filename . '"' );
//$cmd = "mysqldump -u ssf_wx3 --password=ssf_ceas --disable-keys --no-create-info --skip-add-locks --where=\"session_id='".$session_id['max_id']."'\" ssf_laser t_session_val | gzip --best";
$cmd = "mysqldump -u ".$username." --password=".$password." --insert-ignore --disable-keys --no-create-info --skip-add-locks --where=\"session_id='".$session_id['max_id']."' AND host NOT LIKE 'self'\" ".$dbname." t_session_val";
passthru( $cmd );
//echo $cmd;
exit(0);
?>