public function __construct(Runner $runner) { // Register an rsync source backup scheme Factory::register('source', 'rsync', RsyncSource::class); // Load the configuration values $this->config = config('backups/' . $this->identifier); $this->runner = $runner; parent::__construct(); }
/** * Creates a phpbu configuration. * * @return \phpbu\App\Configuration */ protected function createConfiguration() { // check if a phpbu xml/json config file is configured $phpbuConfigFile = $this->configProxy->get('phpbu.phpbu'); if (!empty($phpbuConfigFile)) { // load xml or json configurations $configLoader = PhpbuConfigLoaderFactory::createLoader($phpbuConfigFile); $configuration = $configLoader->getConfiguration(); } else { $this->validateConfig(); // no phpbu config so translate the laravel settings $translator = new Translator(); $configuration = $translator->translate($this->configProxy); // in laravel mode we sync everything using the Laravel Filesystems PhpbuFactory::register('sync', 'laravel-storage', '\\phpbu\\Laravel\\Backup\\Sync\\LaravelStorage'); } return $configuration; }
/** * Execute the cleanup. * * @param \phpbu\App\Configuration\Backup $backup * @param \phpbu\App\Backup\Target $target * @param \phpbu\App\Backup\Collector $collector * @throws \Exception */ protected function executeCleanup(Configuration\Backup $backup, Target $target, Collector $collector) { $cleanup = $backup->getCleanup(); if (!empty($cleanup)) { try { $this->result->cleanupStart($cleanup); if ($this->failure && $cleanup->skipOnFailure) { $this->result->cleanupSkipped($cleanup); } else { $cleaner = $this->factory->createCleaner($cleanup->type, $cleanup->options); $cleaner->cleanup($target, $collector, $this->result); $this->result->cleanupEnd($cleanup); } } catch (Backup\Cleaner\Exception $e) { $this->failure = true; $this->result->addError($e); $this->result->cleanupFailed($cleanup); } } }
/** * Tests Factory::register * * @depends testRegisterExistingCheck */ public function testRegisterExistingCheckForce() { Factory::register('check', 'sizemin', '\\phpbu\\App\\phpbuAppFactoryTestCheck', true); $factory = new Factory(); $dummy = $factory->create('check', 'sizemin'); $this->assertEquals(get_class($dummy), 'phpbu\\App\\phpbuAppFactoryTestCheck', 'Factory should create dummy object'); }
public function register() { // Allow PHPBU to use our defined Laravel filesystems Factory::register('sync', 'laravel-storage', LaravelStorage::class, true); }