Skip to content
Permalink
Browse files

Fixed service name display issue. Added usemail option for PHP mail()…

… support. Fixed block display in restore shell. Added stats shell command. Improved stats display.
  • Loading branch information...
cubiclesoft committed Mar 30, 2016
1 parent 4067ff6 commit ebe37e44083090c3de7a92b3f26ef2012b21ee4e
Showing with 95 additions and 25 deletions.
  1. +3 −0 backup.php
  2. +24 −10 configure.php
  3. +3 −0 restore.php
  4. +55 −14 restore_shell_exts/main.php
  5. +1 −0 support/cb_functions.php
  6. +3 −0 test_service.php
  7. +6 −1 verify.php
@@ -74,6 +74,9 @@
$incrementals = $result["incrementals"];
$lastbackupid = $result["summary"]["lastbackupid"];
$services = CB_GetBackupServices();
if (isset($services[$servicename])) $servicename = $services[$servicename];
// Merge down incrementals.
while (count($incrementals) > $config["numincrementals"] + 1)
{
@@ -250,21 +250,35 @@ function SetupPaths($configkey, $pathsstr, $checkpaths = true)
$from = trim(fgets(STDIN));
echo "Subject line (e.g. [Backup] Some computer name): ";
$subject = trim(fgets(STDIN));
echo "SMTP server (without port): ";
$server = trim(fgets(STDIN));
echo "SMTP port (usually 25, 465, or 587): ";
$port = (int)trim(fgets(STDIN));
echo "SMTP over SSL/TLS (Y/N): ";
$secure = (substr(strtoupper(trim(fgets(STDIN))), 0, 1) == "Y");
echo "SMTP username (optional): ";
$username = trim(fgets(STDIN));
echo "SMTP password (optional): ";
$password = trim(fgets(STDIN));
echo "PHP mail() command (Y/N): ";
$usemail = (substr(strtoupper(trim(fgets(STDIN))), 0, 1) == "Y");
if ($usemail)
{
$server = "";
$port = 25;
$secure = false;
$username = "";
$password = "";
}
else
{
echo "SMTP server (without port): ";
$server = trim(fgets(STDIN));
echo "SMTP port (usually 25, 465, or 587): ";
$port = (int)trim(fgets(STDIN));
echo "SMTP over SSL/TLS (Y/N): ";
$secure = (substr(strtoupper(trim(fgets(STDIN))), 0, 1) == "Y");
echo "SMTP username (optional): ";
$username = trim(fgets(STDIN));
echo "SMTP password (optional): ";
$password = trim(fgets(STDIN));
}
$data = array(
"filter" => $filter,
"from" => $from,
"subject" => $subject,
"usemail" => $usemail,
"server" => $server,
"port" => $port,
"secure" => $secure,
@@ -30,6 +30,9 @@
$incrementaltimes = $result["summary"]["incrementaltimes"];
$lastbackupid = $result["summary"]["lastbackupid"];
$services = CB_GetBackupServices();
if (isset($services[$servicename])) $servicename = $services[$servicename];
function CleanupCache()
{
global $rootpath;
@@ -181,7 +181,7 @@ function shell_cmd_ls($line)
else $attr .= "-";
// Output: Attributes Owner Group Created Filesize[ Blocknum]
echo $attr . " " . sprintf("%-" . $maxowner . "s", $info["owner"]) . " " . sprintf("%-" . $maxgroup . "s", $info["group"]) . " " . sprintf("%" . $maxfullsize . "s", number_format($info["filesize"], 0)) . ($blocks ? " " . $info["blocknum"] : "") . " " . date("Y-M-d h:i A", $info["created"]) . " ";
echo $attr . " " . sprintf("%-" . $maxowner . "s", $info["owner"]) . " " . sprintf("%-" . $maxgroup . "s", $info["group"]) . " " . sprintf("%" . $maxfullsize . "s", number_format($info["filesize"], 0)) . ($blocks ? " " . sprintf("%" . $maxblocknumsize . "s", $info["blocknum"]) : "") . " " . date("Y-M-d h:i A", $info["created"]) . " ";
}
echo $name;
@@ -268,24 +268,65 @@ function shell_cmd_chdir($line)
shell_cmd_cd($line);
}
function shell_cmd_restore($line)
function shell_cmd_stats($line)
{
global $rootpath, $blocklist, $servicehelper, $config, $cb_messages;
global $db;
if (is_array($line)) $args = $line;
else
$options = array(
"shortmap" => array(
"?" => "help"
),
"rules" => array(
"help" => array("arg" => false)
)
);
$args = ParseCommandLine($options, $line);
if (count($args["params"]) > 0 || isset($args["opts"]["help"]))
{
$options = array(
"shortmap" => array(
"?" => "help"
),
"rules" => array(
"help" => array("arg" => false)
)
);
$args = ParseCommandLine($options, $line);
echo $args["file"] . " - Stats command\n";
echo "Purpose: Display database-wide statistics.\n";
echo "\n";
echo "Syntax: " . $args["file"] . " [options]\n";
echo "Options:\n";
echo "\t-? This help documentation.\n";
echo "\n";
echo "Example: " . $args["file"] . " /\n";
return;
}
$numfiles = (int)$db->GetOne("SELECT", array("COUNT(*)", "FROM" => "?", "WHERE" => "blocknum > 0 AND sharedblock = 0"), "files");
$numsharedfiles = (int)$db->GetOne("SELECT", array("COUNT(*)", "FROM" => "?", "WHERE" => "blocknum > 0 AND sharedblock = 1"), "files");
$numsharedblocks = (int)$db->GetOne("SELECT", array("COUNT(DISTINCT blocknum)", "FROM" => "?", "WHERE" => "blocknum > 0 AND sharedblock = 1"), "files");
$numemptyfiles = (int)$db->GetOne("SELECT", array("COUNT(*)", "FROM" => "?", "WHERE" => "blocknum = 0 AND sharedblock = 1"), "files");
$numsymlinks = (int)$db->GetOne("SELECT", array("COUNT(*)", "FROM" => "?", "WHERE" => "blocknum = 0 AND sharedblock = 0 AND symlink <> ''"), "files");
$numdirs = (int)$db->GetOne("SELECT", array("COUNT(*)", "FROM" => "?", "WHERE" => "blocknum = 0 AND sharedblock = 0 AND symlink = ''"), "files");
echo "Symlinks: " . number_format($numsymlinks, 0) . "\n";
echo "Folders: " . number_format($numdirs, 0) . "\n";
echo "Files:\n";
echo "\t" . number_format($numsharedfiles, 0) . " shared (" . number_format($numsharedblocks, 0) . " blocks)\n";
echo "\t" . number_format($numfiles, 0) . " non-shared\n";
echo "\t" . number_format($numemptyfiles, 0) . " empty\n";
echo "\t" . number_format($numsharedfiles + $numfiles + $numemptyfiles, 0) . " total (" . number_format($numsharedblocks + $numfiles, 0) . " blocks)\n";
echo "\n";
}
function shell_cmd_restore($line)
{
global $rootpath, $blocklist, $servicehelper, $config, $cb_messages;
$options = array(
"shortmap" => array(
"?" => "help"
),
"rules" => array(
"help" => array("arg" => false)
)
);
$args = ParseCommandLine($options, $line);
if (count($args["params"]) > 1 || isset($args["opts"]["help"]))
{
echo $args["file"] . " - Restore command\n";
@@ -42,6 +42,7 @@ function CB_SendNotificationEmail($notificationinfo, $htmlmsg, $textmsg)
"headers" => $headers,
"htmlmessage" => $htmlmsg,
"textmessage" => $textmsg,
"usemail" => $notificationinfo["usemail"],
"server" => $notificationinfo["server"],
"port" => $notificationinfo["port"],
"secure" => $notificationinfo["secure"],
@@ -25,6 +25,9 @@
$servicename = $result["servicename"];
$service = $result["service"];
$services = CB_GetBackupServices();
if (isset($services[$servicename])) $servicename = $services[$servicename];
echo "Testing " . $servicename . "...\n";
$service->Test();
@@ -122,13 +122,18 @@ function CleanupCache()
echo "\tRetrieving files database statistics...\n";
$numfiles = (int)$db->GetOne("SELECT", array("COUNT(*)", "FROM" => "?", "WHERE" => "blocknum > 0 AND sharedblock = 0"), "files");
$numsharedfiles = (int)$db->GetOne("SELECT", array("COUNT(*)", "FROM" => "?", "WHERE" => "blocknum > 0 AND sharedblock = 1"), "files");
$numsharedblocks = (int)$db->GetOne("SELECT", array("COUNT(DISTINCT blocknum)", "FROM" => "?", "WHERE" => "blocknum > 0 AND sharedblock = 1"), "files");
$numemptyfiles = (int)$db->GetOne("SELECT", array("COUNT(*)", "FROM" => "?", "WHERE" => "blocknum = 0 AND sharedblock = 1"), "files");
$numsymlinks = (int)$db->GetOne("SELECT", array("COUNT(*)", "FROM" => "?", "WHERE" => "blocknum = 0 AND sharedblock = 0 AND symlink <> ''"), "files");
$numdirs = (int)$db->GetOne("SELECT", array("COUNT(*)", "FROM" => "?", "WHERE" => "blocknum = 0 AND sharedblock = 0 AND symlink = ''"), "files");
echo "\tSymlinks: " . number_format($numsymlinks, 0) . "\n";
echo "\tFolders: " . number_format($numdirs, 0) . "\n";
echo "\tFiles: " . number_format($numsharedfiles, 0) . " shared, " . number_format($numfiles, 0) . " non-shared, " . number_format($numemptyfiles, 0) . " empty, " . number_format($numsharedfiles + $numfiles + $numemptyfiles, 0) . " total\n";
echo "\tFiles:\n";
echo "\t\t" . number_format($numsharedfiles, 0) . " shared (" . number_format($numsharedblocks, 0) . " blocks)\n";
echo "\t\t" . number_format($numfiles, 0) . " non-shared\n";
echo "\t\t" . number_format($numemptyfiles, 0) . " empty\n";
echo "\t\t" . number_format($numsharedfiles + $numfiles + $numemptyfiles, 0) . " total (" . number_format($numsharedblocks + $numfiles, 0) . " blocks)\n";
// Verify that all blocks in the database are in the block list.
echo "\tRetrieving all unique blocks in the database...\n";

0 comments on commit ebe37e4

Please sign in to comment.
You can’t perform that action at this time.