Exemple #1
0
 /**
  * Setup.
  *
  * @see    \phpbu\App\Backup\Source
  * @param  array $conf
  * @throws \phpbu\App\Exception
  */
 public function setup(array $conf = array())
 {
     $this->setupSourceData($conf);
     // environment settings
     $this->pathToElasticdump = Util\Arr::getValue($conf, 'pathToElasticdump');
     $this->host = Util\Arr::getValue($conf, 'host', 'http://localhost:9200');
     $this->user = Util\Arr::getValue($conf, 'user');
     $this->password = Util\Arr::getValue($conf, 'password');
     $this->showStdErr = Util\Str::toBoolean(Util\Arr::getValue($conf, 'showStdErr', ''), false);
 }
Exemple #2
0
 /**
  * Setup.
  *
  * @see    \phpbu\App\Backup\Source
  * @param  array $conf
  * @throws \phpbu\App\Exception
  */
 public function setup(array $conf = array())
 {
     $this->pathToTar = Util\Arr::getValue($conf, 'pathToTar');
     $this->showStdErr = Util\Str::toBoolean(Util\Arr::getValue($conf, 'showStdErr', ''), false);
     $this->path = Util\Arr::getValue($conf, 'path');
     $this->removeDir = Util\Str::toBoolean(Util\Arr::getValue($conf, 'removeDir', ''), false);
     if (empty($this->path)) {
         throw new Exception('path option is mandatory');
     }
 }
Exemple #3
0
 /**
  * Setup.
  *
  * @see    \phpbu\App\Backup\Source
  * @param  array $conf
  * @throws \phpbu\App\Exception
  */
 public function setup(array $conf = array())
 {
     $this->pathToRedisCli = Util\Arr::getValue($conf, 'pathToRedisCli');
     $this->showStdErr = Util\Str::toBoolean(Util\Arr::getValue($conf, 'showStdErr', ''), false);
     $this->pathToRedisData = Util\Arr::getValue($conf, 'pathToRedisData');
     $this->timeout = Util\Arr::getValue($conf, 'timeout', 45);
     $this->host = Util\Arr::getValue($conf, 'host');
     $this->port = Util\Arr::getValue($conf, 'port');
     $this->password = Util\Arr::getValue($conf, 'password');
     if (empty($this->pathToRedisData)) {
         throw new Exception('pathToRedisData option is mandatory');
     }
 }
Exemple #4
0
 /**
  * Setup the the Cleaner.
  *
  * @see    \phpbu\App\Backup\Cleanup::setup()
  * @param  array $options
  * @throws \phpbu\App\Backup\Cleaner\Exception
  */
 public function setup(array $options)
 {
     if (!isset($options['size'])) {
         throw new Exception('option \'size\' is missing');
     }
     try {
         $bytes = Str::toBytes($options['size']);
     } catch (RuntimeException $e) {
         throw new Exception($e->getMessage());
     }
     $this->deleteTarget = isset($options['deleteTarget']) ? Str::toBoolean($options['deleteTarget'], false) : false;
     $this->capacityRaw = $options['size'];
     $this->capacityBytes = $bytes;
 }
Exemple #5
0
 /**
  * Setup.
  *
  * @see    \phpbu\App\Backup\Crypter
  * @param  array $options
  * @throws Exception
  */
 public function setup(array $options = array())
 {
     if (!Util\Arr::isSetAndNotEmptyString($options, 'algorithm')) {
         throw new Exception('openssl expects \'algorithm\'');
     }
     if (!Util\Arr::isSetAndNotEmptyString($options, 'password') && !Util\Arr::isSetAndNotEmptyString($options, 'certFile')) {
         throw new Exception('openssl expects \'key\' or \'password\'');
     }
     $this->pathToOpenSSL = Util\Arr::getValue($options, 'pathToOpenSSL');
     $this->showStdErr = Util\Str::toBoolean(Util\Arr::getValue($options, 'showStdErr', ''), false);
     $this->keepUncrypted = Util\Str::toBoolean(Util\Arr::getValue($options, 'keepUncrypted', ''), false);
     $this->certFile = $this->toAbsolutePath(Util\Arr::getValue($options, 'certFile'));
     $this->algorithm = Util\Arr::getValue($options, 'algorithm');
     $this->password = Util\Arr::getValue($options, 'password');
 }
Exemple #6
0
 /**
  * Setup.
  *
  * @see    \phpbu\App\Backup\Crypter
  * @param  array $options
  * @throws Exception
  */
 public function setup(array $options = array())
 {
     if (!Util\Arr::isSetAndNotEmptyString($options, 'algorithm')) {
         throw new Exception('mcrypt \'algorithm\' is mandatory');
     }
     $this->pathToMcrypt = Util\Arr::getValue($options, 'pathToMcrypt');
     $this->showStdErr = Util\Str::toBoolean(Util\Arr::getValue($options, 'showStdErr', ''), false);
     $this->keepUncrypted = Util\Str::toBoolean(Util\Arr::getValue($options, 'keepUncrypted', ''), false);
     $this->key = Util\Arr::getValue($options, 'key');
     $this->keyFile = $this->toAbsolutePath(Util\Arr::getValue($options, 'keyFile'));
     $this->algorithm = $options['algorithm'];
     $this->hash = Util\Arr::getValue($options, 'hash');
     $this->config = $this->toAbsolutePath(Util\Arr::getValue($options, 'config'));
     if (empty($this->key) && empty($this->keyFile)) {
         throw new Exception('one of \'key\' or \'keyFile\' is mandatory');
     }
 }
Exemple #7
0
 /**
  * (No PHPDoc)
  *
  * @see    \phpbu\App\Backup\Source
  * @param  array $conf
  * @throws \phpbu\App\Exception
  */
 public function setup(array $conf = array())
 {
     $this->setupSourceData($conf);
     $this->setupCredentials($conf);
     // environment settings, config & validation
     $this->pathToMongodump = Util\Arr::getValue($conf, 'pathToMongodump');
     $this->useIPv6 = Util\Str::toBoolean(Util\Arr::getValue($conf, 'ipv6', ''), false);
     $this->showStdErr = Util\Str::toBoolean(Util\Arr::getValue($conf, 'showStdErr', ''), false);
 }
Exemple #8
0
 /**
  * Setup.
  *
  * @see    \phpbu\App\Backup\Source
  * @param  array $conf
  * @throws \phpbu\App\Exception
  */
 public function setup(array $conf = array())
 {
     $this->setupSourceData($conf);
     $this->pathToXtraBackup = Util\Arr::getValue($conf, 'pathToXtraBackup');
     $this->dataDir = Util\Arr::getValue($conf, 'dataDir');
     $this->host = Util\Arr::getValue($conf, 'host');
     $this->user = Util\Arr::getValue($conf, 'user');
     $this->password = Util\Arr::getValue($conf, 'password');
     $this->showStdErr = Util\Str::toBoolean(Util\Arr::getValue($conf, 'showStdErr', ''), false);
 }
Exemple #9
0
 /**
  * Setup.
  *
  * @see    \phpbu\App\Backup\Source
  * @param  array $conf
  * @throws \phpbu\App\Exception
  */
 public function setup(array $conf = array())
 {
     $this->setupSourceData($conf);
     $this->pathToMysqldump = Util\Arr::getValue($conf, 'pathToMysqldump');
     $this->host = Util\Arr::getValue($conf, 'host');
     $this->user = Util\Arr::getValue($conf, 'user');
     $this->password = Util\Arr::getValue($conf, 'password');
     $this->showStdErr = Util\Str::toBoolean(Util\Arr::getValue($conf, 'showStdErr', ''), false);
     $this->hexBlob = Util\Str::toBoolean(Util\Arr::getValue($conf, 'hexBlob', ''), false);
     $this->quick = Util\Str::toBoolean(Util\Arr::getValue($conf, 'quick', ''), false);
     $this->lockTables = Util\Str::toBoolean(Util\Arr::getValue($conf, 'lockTables', ''), false);
     $this->compress = Util\Str::toBoolean(Util\Arr::getValue($conf, 'compress', ''), false);
     $this->extendedInsert = Util\Str::toBoolean(Util\Arr::getValue($conf, 'extendedInsert', ''), false);
     $this->noData = Util\Str::toBoolean(Util\Arr::getValue($conf, 'noData', ''), false);
 }
Exemple #10
0
 /**
  * Setup the Logger.
  *
  * @see    \phpbu\Log\Logger::setup
  * @param  array $options
  * @throws \phpbu\App\Exception
  */
 public function setup(array $options)
 {
     if (empty($options['recipients'])) {
         throw new Exception('no recipients given');
     }
     $mails = $options['recipients'];
     $server = gethostname();
     $this->sendOnlyOnError = Str::toBoolean(Arr::getValue($options, 'sendOnlyOnError'), false);
     $this->subject = Arr::getValue($options, 'subject', 'PHPBU backup report from ' . $server);
     $this->senderMail = Arr::getValue($options, 'sender.mail', 'phpbu@' . $server);
     $this->senderName = Arr::getValue($options, 'sender.name');
     $this->transportType = Arr::getValue($options, 'transport', 'mail');
     $this->recipients = array_map('trim', explode(';', $mails));
     // create transport an mailer
     $transport = $this->createTransport($this->transportType, $options);
     $this->mailer = Swift_Mailer::newInstance($transport);
 }
Exemple #11
0
 /**
  * (non-PHPDoc)
  *
  * @see    \phpbu\App\Backup\Sync::setup()
  * @param  array $options
  * @throws \phpbu\App\Backup\Sync\Exception
  */
 public function setup(array $options)
 {
     $this->pathToRsync = Util\Arr::getValue($options, 'pathToRsync');
     if (Util\Arr::isSetAndNotEmptyString($options, 'args')) {
         $this->args = $options['args'];
     } else {
         if (!Util\Arr::isSetAndNotEmptyString($options, 'path')) {
             throw new Exception('option \'path\' is missing');
         }
         $this->path = Util\Str::replaceDatePlaceholders($options['path']);
         if (Util\Arr::isSetAndNotEmptyString($options, 'user')) {
             $this->user = $options['user'];
         }
         if (Util\Arr::isSetAndNotEmptyString($options, 'host')) {
             $this->host = $options['host'];
         }
         $this->excludes = Util\Str::toList(Util\Arr::getValue($options, 'exclude', ''), ':');
         $this->delete = Util\Str::toBoolean(Util\Arr::getValue($options, 'delete', ''), false);
         $this->isDirSync = Util\Str::toBoolean(Util\Arr::getValue($options, 'dirsync', ''), false);
     }
 }
Exemple #12
0
 /**
  * Get collections and data to backup.
  *
  * @param array $conf
  */
 protected function setupSourceData(array $conf)
 {
     $this->dumpData = Util\Str::toBoolean(Util\Arr::getValue($conf, 'dumpData'), false);
     $this->includeSystemCollections = Util\Str::toBoolean(Util\Arr::getValue($conf, 'includeSystemCollections'), false);
     $this->collections = Util\Str::toList(Util\Arr::getValue($conf, 'collections'));
 }
Exemple #13
0
 /**
  * Set the cleanup configuration.
  *
  * @param  \phpbu\App\Configuration\Backup $backup
  * @param  \DOMElement                     $node
  * @throws \phpbu\App\Exception
  */
 protected function setCleanup(Configuration\Backup $backup, DOMElement $node)
 {
     /** @var \DOMNodeList $cleanupNodes */
     $cleanupNodes = $node->getElementsByTagName('cleanup');
     if ($cleanupNodes->length > 0) {
         /** @var \DOMElement $cleanupNode */
         $cleanupNode = $cleanupNodes->item(0);
         $type = $cleanupNode->getAttribute('type');
         if (!$type) {
             throw new Exception('invalid cleanup configuration: attribute type missing');
         }
         $skip = Str::toBoolean($cleanupNode->getAttribute('skipOnFailure'), true);
         $options = $this->getOptions($cleanupNode);
         $backup->setCleanup(new Configuration\Backup\Cleanup($type, $skip, $options));
     }
 }