Пример #1
0
 /**
  * Test Sync handling.
  */
 public function testSync()
 {
     $sync = new Configuration\Backup\Sync('rsync', false);
     $backup = new Backup('name');
     $backup->syncAdd($sync);
     $backup->syncFailed($sync);
     $backup->syncSkipped($sync);
     $this->assertEquals(1, $backup->syncCountFailed());
     $this->assertEquals(1, $backup->syncCountSkipped());
     $this->assertEquals(1, $backup->syncCount());
 }
Пример #2
0
 /**
  * Prints verbose backup information.
  *
  * @param \phpbu\App\Result\Backup $backup
  */
 protected function printBackupVerbose(Result\Backup $backup)
 {
     $this->write(sprintf('backup %s: ', $backup->getName()));
     if ($backup->allOk()) {
         $this->writeWithColor('fg-black, bg-green', 'OK');
     } elseif ($backup->okButSkipsOrFails()) {
         $this->writeWithColor('fg-black, bg-yellow', 'OK, but skipped or failed Crypts, Syncs or Cleanups!');
     } else {
         $this->writeWithColor('fg-white, bg-red, bold', 'FAILED');
     }
     $chExecuted = str_pad($backup->checkCount(), 8, ' ', STR_PAD_LEFT);
     $chFailed = str_pad($backup->checkCountFailed(), 6, ' ', STR_PAD_LEFT);
     $crExecuted = str_pad($backup->cryptCount(), 8, ' ', STR_PAD_LEFT);
     $crSkipped = str_pad($backup->cryptCountSkipped(), 7, ' ', STR_PAD_LEFT);
     $crFailed = str_pad($backup->cryptCountFailed(), 6, ' ', STR_PAD_LEFT);
     $syExecuted = str_pad($backup->syncCount(), 8, ' ', STR_PAD_LEFT);
     $sySkipped = str_pad($backup->syncCountSkipped(), 7, ' ', STR_PAD_LEFT);
     $syFailed = str_pad($backup->syncCountFailed(), 6, ' ', STR_PAD_LEFT);
     $clExecuted = str_pad($backup->cleanupCount(), 8, ' ', STR_PAD_LEFT);
     $clSkipped = str_pad($backup->cleanupCountSkipped(), 7, ' ', STR_PAD_LEFT);
     $clFailed = str_pad($backup->cleanupCountFailed(), 6, ' ', STR_PAD_LEFT);
     $out = PHP_EOL . '          | executed | skipped | failed |' . PHP_EOL . '----------+----------+---------+--------+' . PHP_EOL . ' checks   | ' . $chExecuted . ' |         | ' . $chFailed . ' |' . PHP_EOL . ' crypts   | ' . $crExecuted . ' | ' . $crSkipped . ' | ' . $crFailed . ' |' . PHP_EOL . ' syncs    | ' . $syExecuted . ' | ' . $sySkipped . ' | ' . $syFailed . ' |' . PHP_EOL . ' cleanups | ' . $clExecuted . ' | ' . $clSkipped . ' | ' . $clFailed . ' |' . PHP_EOL . '----------+----------+---------+--------+' . PHP_EOL . PHP_EOL;
     $this->write($out);
 }