kontrolvm/dbBackup.php
KuJoe 248ea0972f
Some checks are pending
PHPMD / Run PHPMD scanning (push) Waiting to run
Psalm Security Scan / php-security (push) Waiting to run
Added proper logging and reporting.
This is just an initial pass of retrofitting the code to handle better logging and reporting (issue #3), but more work may be required.
2025-03-04 12:56:18 -05:00

24 lines
No EOL
518 B
PHP

<?php
require_once('config.php');
$backup_file_path = $db_file_path.".bak";
try {
$conn = new SQLite3($db_file_path, SQLITE3_OPEN_READONLY);
$backup_db = new SQLite3($backup_file_path);
$result = $conn->backup($backup_db);
if($result) {
updateLastRunTime('dbBackup.php');
return;
} else {
error_log("Error creating DB backup: ". $conn->lastErrorMsg());
return;
}
$conn->close();
$backup_db->close();
} catch (Exception $e) {
error_log("Error creating DB backup: ". $e->getMessage());
return;
}
?>