コード例 #1
0
ファイル: BackupCronCommand.php プロジェクト: kriskbx/wyn
 /**
  * Execute Command.
  *
  * @param InputInterface  $consoleInput
  * @param OutputInterface $consoleOutput
  *
  * @throws PathNotFoundException
  * @throws \Exception
  * @throws \kriskbx\wyn\Exceptions\PropertyNotSetException
  *
  * @return int|null|void
  */
 public function execute(InputInterface $consoleInput, OutputInterface $consoleOutput)
 {
     parent::execute($consoleInput, $consoleOutput);
     // Create Config
     $config = new YamlConfig(new Yaml(), $consoleInput->getArgument('config'));
     // Create console output logger
     $console = $this->createConsoleOutput($this);
     // Set empty cron object
     $cron = null;
     // Loop through all inputs
     foreach ($config->getAllInputs() as $inputName) {
         if (!isset($config->getInput($inputName)['to']) || !isset($config->getInput($inputName)['cron'])) {
             continue;
         }
         // Create settings and set timezone before the actual backup
         $settings = $this->createSettings($inputName, $this->getOutputNames($consoleInput, $config, $inputName)[0], $consoleInput, $config);
         $this->setTimezone($settings);
         // Create cron object if it isn't already set
         $this->assertCron($cron, $settings);
         // Assert that the job is added to the cron object and up-to-date
         $this->assertJob($config, $inputName, $cron);
         // Start the backup if the job should run
         if ($cron->get($inputName)->shouldRun()) {
             $cron->started($inputName);
             $this->backup($inputName, $consoleInput, $consoleOutput, $config, $console);
         }
     }
     // Display the Finished Message
     $this->finished($consoleOutput);
 }
コード例 #2
0
ファイル: BackupSingleCommand.php プロジェクト: kriskbx/wyn
 /**
  * Execute Command.
  *
  * @param InputInterface  $consoleInput
  * @param OutputInterface $consoleOutput
  *
  * @throws PathNotFoundException
  * @throws \Exception
  * @throws \kriskbx\wyn\Exceptions\PropertyNotSetException
  *
  * @return int|null|void
  */
 public function execute(InputInterface $consoleInput, OutputInterface $consoleOutput)
 {
     parent::execute($consoleInput, $consoleOutput);
     // Create Config
     $config = new YamlConfig(new Yaml(), $consoleInput->getArgument('config'));
     // Run backup
     $this->backup($consoleInput->getArgument('input'), $consoleInput, $consoleOutput, $config, $this->createConsoleOutput($this));
     // Display the Finished Message
     $this->finished($consoleOutput);
 }
コード例 #3
0
ファイル: BackupDaemonCommand.php プロジェクト: kriskbx/wyn
 /**
  * Execute Command.
  *
  * @param InputInterface  $consoleInput
  * @param OutputInterface $consoleOutput
  *
  * @throws PathNotFoundException
  * @throws \Exception
  * @throws \kriskbx\wyn\Exceptions\PropertyNotSetException
  *
  * @return int|null|void
  */
 public function execute(InputInterface $consoleInput, OutputInterface $consoleOutput)
 {
     parent::execute($consoleInput, $consoleOutput);
     GlobalConfig::preFlight($consoleOutput);
     $this->sleep = $consoleInput->getOption('interval');
     $this->workerCommand = $this->buildWorkerCommand();
     $process = $this->makeProcess();
     $consoleOutput->writeln('<info>Daemon started...</info>');
     while (true) {
         $consoleOutput->writeln('<info>Running backup:cron...</info>');
         $process->run(function ($type, $line) {
             $this->output->writeln($line);
         });
         sleep($this->sleep);
     }
 }
コード例 #4
0
ファイル: BackupAllCommand.php プロジェクト: kriskbx/wyn
 /**
  * Execute Command.
  *
  * @param InputInterface  $consoleInput
  * @param OutputInterface $consoleOutput
  *
  * @throws PathNotFoundException
  * @throws \Exception
  * @throws \kriskbx\wyn\Exceptions\PropertyNotSetException
  *
  * @return int|null|void
  */
 public function execute(InputInterface $consoleInput, OutputInterface $consoleOutput)
 {
     parent::execute($consoleInput, $consoleOutput);
     // Create config
     $config = new YamlConfig(new Yaml(), $consoleInput->getArgument('config'));
     // Create console output logger
     $console = $this->createConsoleOutput($this);
     // Loop through all inputs
     foreach ($config->getAllInputs() as $inputName) {
         if (!isset($config->getInput($inputName)['to'])) {
             continue;
         }
         $this->backup($inputName, $consoleInput, $consoleOutput, $config, $console);
     }
     // Display the Finished Message
     $this->finished($consoleOutput);
 }
コード例 #5
0
ファイル: DecryptCommand.php プロジェクト: kriskbx/wyn
 /**
  * Execute Command.
  *
  * @param InputInterface  $consoleInput
  * @param OutputInterface $consoleOutput
  *
  * @return int|null|void
  *
  * @throws PathNotFoundException
  */
 public function execute(InputInterface $consoleInput, OutputInterface $consoleOutput)
 {
     parent::execute($consoleInput, $consoleOutput);
     if (!file_exists($consoleInput->getArgument('target')) || !is_dir($consoleInput->getArgument('target'))) {
         throw new PathNotFoundException($consoleInput->getArgument('target'));
     }
     // Get Config
     $config = new YamlConfig(new Yaml(), $consoleInput->getArgument('config'));
     // Create IO Handler
     $inputHandler = $this->createOutput($consoleInput->getArgument('output'), $config);
     $outputHandler = new LocalOutput($consoleInput->getArgument('target'));
     // Console output
     $console = $this->createConsoleOutput($this);
     // Crypto
     $crypto = new EncryptionMiddleware($inputHandler->config('encrypt'));
     $crypto->decrypt($inputHandler, $outputHandler, $console);
     // Finished
     $this->finished($consoleOutput);
 }