function getScheduledBackup() { if (!is_object($this->scheduledBackup)) { $info = $this->getInfo(); $scheduledBackupGetter = new scheduledBackupGetter(); $this->scheduledBackup = $scheduledBackupGetter->getById($info['scheduled_backup_id']); } return $this->scheduledBackup; }
function getScheduledBackup() { if (!is_numeric($this->id)) { throw new Exception('backupJob->getInfo: ' . "Error: The ID for this object is not an integer."); } $info = $this->getInfo(); $scheduledBackupGetter = new scheduledBackupGetter(); $scheduledBackupGetter->setLogStream($this->log); return $scheduledBackupGetter->getById($info['scheduled_backup_id']); }
function getScheduledBackup() { $this->__validate(); $info = $this->getInfo(); $scheduledBackupGetter = new scheduledBackupGetter(); $this->scheduledBackup = $scheduledBackupGetter->getById($info['scheduled_backup_id']); return $this->scheduledBackup; }
function handleStatusAction() { $backupJobGetter = new backupJobGetter(); $backupJobGetter->setLogStream($this->log); $scheduledBackupGetter = new scheduledBackupGetter(); $scheduledBackupGetter->setLogStream($this->log); $hostGetter = new hostGetter(); $hostGetter->setLogStream($this->log); $runningJobs = $backupJobGetter->getRunning(); $backupRows = array(); foreach ($runningJobs as $job) { $info = $job->getInfo(); $scheduledBackup = $job->getScheduledBackup(); $host = $scheduledBackup->getHost(); $hostInfo = $host->getInfo(); $sbInfo = $scheduledBackup->getInfo(); $backupRows[] = array('Job ID' => $info['backup_job_id'], 'Host' => $hostInfo['hostname'], 'Backup Name' => $sbInfo['name'], 'Start Time' => $info['start_time'], 'Status' => $info['status'], 'PID' => $info['pid']); } if (sizeOf($backupRows) > 0) { $textTable = new ArrayToTextTable($backupRows); $textTable->showHeaders(true); $tableOutput = $textTable->render(true); print "Currently Running Backups:\n\n" . $tableOutput . "\n\n"; } else { print "There are no backups currently running.\n\n"; } }
function getStagingTmpdir() { global $config; if (!is_numeric($this->id)) { throw new Exception('runningBackup->getStagingTmpdir: ' . "Error: The ID for this object is not an integer."); } $conn = dbConnection::getInstance($this->log); $info = $this->getInfo(); // Collect the info we need to connect to the remote host $backupGetter = new scheduledBackupGetter(); $scheduledBackup = $backupGetter->getById($info['scheduled_backup_id']); $sbInfo = $scheduledBackup->getInfo(); $host = $scheduledBackup->getHost(); $hostInfo = $host->getInfo(); $this->remoteTempDir = new remoteTempDir(); $tempDir = $this->remoteTempDir->init($hostInfo['hostname'], $hostInfo['ssh_port'], $sbInfo['backup_user'], $hostInfo['staging_path'], 'xbm-'); // Put the path into the DB $sql = "UPDATE running_backups SET staging_tmpdir='" . $conn->real_escape_string($tempDir) . "' WHERE running_backup_id=" . $this->id; if (!$conn->query($sql)) { throw new Exception('runningBackup->getStagingTmpdir: ' . "Error: Query: {$sql} \nFailed with MySQL Error: {$conn->error}"); } return $tempDir; }
function getScheduledBackups() { // Validate this... if (!is_numeric($this->id)) { throw new Exception('backupVolume->getScheduledBackups: ' . "Error: The ID for this object is not an integer."); } global $config; $conn = dbConnection::getInstance($this->log); $sql = "SELECT scheduled_backup_id FROM scheduled_backups WHERE backup_volume_id=" . $this->id; if (!($res = $conn->query($sql))) { throw new DBException('backupVolume->getScheduledBackups: ' . "Error: Query: {$sql} \nFailed with MySQL Error: {$conn->error}"); } $backupGetter = new scheduledBackupGetter(); $backupGetter->setLogStream($this->log); $backups = array(); while ($row = $res->fetch_array()) { $backups[] = $backupGetter->getById($row['scheduled_backup_id']); } return $backups; }