Ejemplo n.º 1
0
 function getRunningBackups()
 {
     global $config;
     if (!is_numeric($this->id)) {
         throw new Exception('host->getRunningBackups: ' . "Error: The ID for this object is not an integer.");
     }
     $backupGetter = new runningBackupGetter();
     $backupGetter->setLogStream($this->log);
     return $backupGetter->getByHost($this);
 }
 function destroy()
 {
     // Validate this...
     if (!is_numeric($this->id)) {
         throw new Exception('scheduledBackup->destroy: ' . "Error: The ID for this object is not an integer.");
     }
     $queueManager = new queueManager();
     $queueManager->setLogStream($this->log);
     // We need to take over all queues for this backup and make sure nothing is running.
     $queues = array('scheduledBackup:' . $this->id, 'retentionApply:' . $this->id, 'postProcess:' . $this->id);
     foreach ($queues as $queue) {
         $ticket = $queueManager->getTicketNumber($queue);
         if (!$queueManager->checkFrontOfQueue($queue, $ticket)) {
             throw new ProcessingException("Error: Cannot remove the Scheduled Backup Task as it is currently running.");
         }
     }
     // Check to see if anything is running for this scheduledBackup
     $runningBackupGetter = new runningBackupGetter();
     $runningBackupGetter->setLogStream($this->log);
     $runningBackups = $runningBackupGetter->getByScheduledBackup($this);
     if (sizeOf($runningBackups) > 0) {
         throw new ProcessingException("Error: Cannot remove the Scheduled Backup Task as it is currently running.");
     }
     // Get all snapshots and destroy them..
     $groups = $this->getSnapshotGroupsNewestToOldest();
     foreach ($groups as $group) {
         $snapshots = $group->getAllSnapshotsNewestToOldest();
         foreach ($snapshots as $snapshot) {
             $snapshot->destroy();
         }
     }
     // If we have a materialized snapshot - destroy that too
     if ($latestMaterialized = $this->getMostRecentCompletedMaterializedSnapshot()) {
         $latestMaterialized->destroy();
     }
     $conn = dbConnection::getInstance($this->log);
     // Remove DB the entries for this scheduledBackup
     $sql = "DELETE sb.*, sbp.* FROM scheduled_backups sb JOIN scheduled_backup_params sbp USING (scheduled_backup_id) WHERE scheduled_backup_id = " . $this->id;
     if (!$conn->query($sql)) {
         throw new DBException('scheduledBackup->setParam: ' . "Error: Query {$sql} \nFailed with MySQL Error: {$conn->error}");
     }
     return;
 }