Ejemplo n.º 1
0
 /**
  * Execute the syncs.
  *
  * @param  \phpbu\App\Configuration\Backup $backup
  * @param  \phpbu\App\Backup\Target        $target
  * @throws \Exception
  */
 protected function executeSyncs(Configuration\Backup $backup, Target $target)
 {
     /** @var \phpbu\App\Configuration\Backup\Sync $sync */
     foreach ($backup->getSyncs() as $sync) {
         try {
             $this->result->syncStart($sync);
             if ($this->failure && $sync->skipOnFailure) {
                 $this->result->syncSkipped($sync);
             } else {
                 $s = $this->factory->createSync($sync->type, $sync->options);
                 $s->sync($target, $this->result);
                 $this->result->syncEnd($sync);
             }
         } catch (Backup\Sync\Exception $e) {
             $this->failure = true;
             $this->result->addError($e);
             $this->result->syncFailed($sync);
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * Tests max Result life cycle with skips.
  */
 public function testBackupMaximalWithSkips()
 {
     $conf = new Configuration('/tmp/foo.xml');
     $backup = new Configuration\Backup('test-backup', false);
     $check = new Configuration\Backup\Check('sizemin', '10M');
     $crypt = new Configuration\Backup\Crypt('mcrypt', false);
     $sync = new Configuration\Backup\Sync('rsync', false);
     $cleanup = new Configuration\Backup\Cleanup('capacity', false);
     $result = new Result();
     $result->phpbuStart($conf);
     $result->backupStart($backup);
     $result->checkStart($check);
     $result->checkEnd($check);
     $result->cryptSkipped($crypt);
     $result->syncSkipped($sync);
     $result->cleanupSkipped($cleanup);
     $result->backupEnd($backup);
     $result->phpbuEnd();
     $this->assertTrue($result->wasSuccessful(), 'should be successful');
     $this->assertFalse($result->allOk(), 'should be ok');
     $this->assertTrue($result->backupOkButSkipsOrFails(), 'crypt, sync and cleanup should be skipped');
     $this->assertEquals(0, $result->syncsFailedCount());
     $this->assertEquals(1, $result->syncsSkippedCount());
     $this->assertEquals(0, $result->cleanupsFailedCount());
     $this->assertEquals(1, $result->cleanupsSkippedCount());
     $this->assertEquals(0, $result->errorCount());
     $this->assertEquals(0, count($result->getErrors()));
     $this->assertEquals(1, count($result->getBackups()));
 }