updating log backup
This commit is contained in:
@@ -59,4 +59,34 @@ function create_dashboard_backup($conn){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function create_server_log_backup($conn){
|
||||||
|
//create a filename
|
||||||
|
$filename="server_log_export_".date('Y-m-d_H-i-s').".csv";
|
||||||
|
|
||||||
|
$fp=fopen("/var/www/html/backup/$filename","w");
|
||||||
|
//do all the logic here and write into file
|
||||||
|
// Query log entries for the export file
|
||||||
|
$sql = "SELECT * FROM machines,vir_notify WHERE machine_name=machine_id ORDER BY vir_notify.id DESC";
|
||||||
|
$stmt = $conn->prepare($sql);
|
||||||
|
|
||||||
|
$stmt->execute();
|
||||||
|
$result = $stmt->get_result();
|
||||||
|
|
||||||
|
fwrite ($fp,"Entry id;Machine id;Machine Location;Path;Hash;Action taken\n");
|
||||||
|
//now add entrys
|
||||||
|
while ($row = $result->fetch_assoc()) {
|
||||||
|
fwrite($fp,$row["id"] . ';');
|
||||||
|
fwrite($fp,$row["machine_id"] . ';');
|
||||||
|
fwrite($fp,$row["machine_location"] . ';');
|
||||||
|
fwrite($fp,$row["path"] . ';');
|
||||||
|
fwrite($fp,$row["hash"] . ';');
|
||||||
|
fwrite($fp,$row["action"] . ";\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose($fp);
|
||||||
|
$stmt->close();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -69,7 +69,7 @@ $conn->close();
|
|||||||
if ($conn->connect_error) {
|
if ($conn->connect_error) {
|
||||||
die("Connection failed: " . $conn->connect_error);
|
die("Connection failed: " . $conn->connect_error);
|
||||||
}
|
}
|
||||||
create_log_backup($conn);
|
create__server_log_backup($conn);
|
||||||
$sql = "DELETE FROM server_log WHERE id = ?";
|
$sql = "DELETE FROM server_log WHERE id = ?";
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->bind_param("i", $id);
|
$stmt->bind_param("i", $id);
|
||||||
@@ -92,7 +92,7 @@ $conn->close();
|
|||||||
if ($conn->connect_error) {
|
if ($conn->connect_error) {
|
||||||
die("Connection failed: " . $conn->connect_error);
|
die("Connection failed: " . $conn->connect_error);
|
||||||
}
|
}
|
||||||
create_log_backup($conn);
|
create__server_log_backup($conn);
|
||||||
$sql = "DELETE FROM server_log";
|
$sql = "DELETE FROM server_log";
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
// Execute the statement
|
// Execute the statement
|
||||||
|
|||||||
Reference in New Issue
Block a user