/** * (non-PHPDoc) * * @see \phpbu\App\Backup\Sync::setup() * @param array $config * @throws \phpbu\App\Backup\Sync\Exception */ public function setup(array $config) { if (!class_exists('\\ObjectStorage')) { throw new Exception('SoftLayer SDK not loaded: use composer "softlayer/objectstorage": "dev-master" to install'); } if (!Arr::isSetAndNotEmptyString($config, 'user')) { throw new Exception('SoftLayer user is mandatory'); } if (!Arr::isSetAndNotEmptyString($config, 'secret')) { throw new Exception('SoftLayer password is mandatory'); } if (!Arr::isSetAndNotEmptyString($config, 'container')) { throw new Exception('SoftLayer container name is mandatory'); } if (!Arr::isSetAndNotEmptyString($config, 'host')) { throw new Exception('SoftLayer host is mandatory'); } if (!Arr::isSetAndNotEmptyString($config, 'path')) { throw new Exception('SoftLayer path is mandatory'); } $this->user = $config['user']; $this->secret = $config['secret']; $this->container = $config['container']; $this->host = $config['host']; $this->path = Str::withLeadingSlash(Str::withTrailingSlash(Str::replaceDatePlaceholders($config['path']))); }
/** * (non-PHPDoc) * * @see \phpbu\App\Backup\Sync::setup() * @param array $config * @throws \phpbu\App\Backup\Sync\Exception */ public function setup(array $config) { if (!class_exists('\\Barracuda\\Copy\\API')) { throw new Exception('Copy api not loaded: use composer "barracuda/copy": "1.1.*" to install'); } if (!Arr::isSetAndNotEmptyString($config, 'app.key')) { throw new Exception('API access key is mandatory'); } if (!Arr::isSetAndNotEmptyString($config, 'app.secret')) { throw new Exception('API access secret is mandatory'); } if (!Arr::isSetAndNotEmptyString($config, 'user.key')) { throw new Exception('User access key is mandatory'); } if (!Arr::isSetAndNotEmptyString($config, 'user.secret')) { throw new Exception('User access secret is mandatory'); } if (!Arr::isSetAndNotEmptyString($config, 'path')) { throw new Exception('copy.com path is mandatory'); } $this->appKey = $config['app.key']; $this->appSecret = $config['app.secret']; $this->userKey = $config['user.key']; $this->userSecret = $config['user.secret']; $this->path = Str::withTrailingSlash(Str::replaceDatePlaceholders($config['path'])); }
/** * 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'); } }
/** * 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'); } }
/** * (non-PHPDoc) * * @see \phpbu\App\Backup\Sync::setup() * @param array $config * @throws \phpbu\App\Backup\Sync\Exception */ public function setup(array $config) { if (!class_exists('\\Mackey\\Yandex\\Client')) { throw new Exception('Yandex.Disk sdk not loaded: use composer to install "arhitector/yandex"'); } if (!Arr::isSetAndNotEmptyString($config, 'token')) { throw new Exception('API access token is mandatory'); } if (!Arr::isSetAndNotEmptyString($config, 'path')) { throw new Exception('yandex.disk path is mandatory'); } $this->token = $config['token']; $this->path = Str::withTrailingSlash(Str::replaceDatePlaceholders($config['path'])); }
/** * (non-PHPDoc) * * @see \phpbu\App\Backup\Sync::setup() * @param array $config * @throws \phpbu\App\Backup\Sync\Exception */ public function setup(array $config) { if (!class_exists('\\Dropbox\\Client')) { throw new Exception('Dropbox sdk not loaded: use composer "dropbox/dropbox-sdk": "1.1.*" to install'); } if (!Arr::isSetAndNotEmptyString($config, 'token')) { throw new Exception('API access token is mandatory'); } if (!Arr::isSetAndNotEmptyString($config, 'path')) { throw new Exception('dropbox path is mandatory'); } $this->token = $config['token']; $this->path = Str::withTrailingSlash(Str::replaceDatePlaceholders($config['path'])); }
/** * 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'); }
public function setup(array $config) { if (!function_exists('ftp_connect')) { throw new Exception('ftp functions not enabled'); } if (!Arr::isSetAndNotEmptyString($config, 'host')) { throw new Exception('option \'host\' is missing'); } if (!Arr::isSetAndNotEmptyString($config, 'user')) { throw new Exception('option \'user\' is missing'); } if (!Arr::isSetAndNotEmptyString($config, 'password')) { throw new Exception('option \'password\' is missing'); } $path = Arr::getValue($config, 'path', ''); if ('/' === substr($path, 0, 1)) { throw new Exception('absolute path is not allowed'); } $this->host = $config['host']; $this->user = $config['user']; $this->password = $config['password']; $this->remotePath = Str::withoutTrailingSlash(Str::replaceDatePlaceholders($path)); }
/** * (non-PHPDoc) * * @see \phpbu\App\Backup\Sync::setup() * @param array $config * @throws \phpbu\App\Backup\Sync\Exception */ public function setup(array $config) { if (!class_exists('\\phpseclib\\Net\\SFTP')) { throw new Exception('phpseclib not installed - use composer to install "phpseclib/phpseclib" version 2.x'); } if (!Arr::isSetAndNotEmptyString($config, 'host')) { throw new Exception('option \'host\' is missing'); } if (!Arr::isSetAndNotEmptyString($config, 'user')) { throw new Exception('option \'user\' is missing'); } if (!Arr::isSetAndNotEmptyString($config, 'password')) { throw new Exception('option \'password\' is missing'); } $path = Arr::getValue($config, 'path', ''); if ('/' === substr($path, 0, 1)) { throw new Exception('absolute path is not allowed'); } $this->host = $config['host']; $this->user = $config['user']; $this->password = $config['password']; $this->remotePath = Str::withoutTrailingSlash(Str::replaceDatePlaceholders($path)); }
/** * Create a application configuration. * * @return \phpbu\App\Configuration */ protected function createConfiguration() { $configLoader = Configuration\Loader\Factory::createLoader($this->arguments['configuration']); $configuration = $configLoader->getConfiguration(); // command line arguments overrule the config file settings if (Arr::getValue($this->arguments, 'verbose') === true) { $configuration->setVerbose(true); } if (Arr::getValue($this->arguments, 'colors') === true) { $configuration->setColors(true); } if (Arr::getValue($this->arguments, 'debug') === true) { $configuration->setDebug(true); } if (Arr::getValue($this->arguments, 'simulate') === true) { $configuration->setSimulate(true); } $bootstrap = Arr::getValue($this->arguments, 'bootstrap'); if (!empty($bootstrap)) { $configuration->setBootstrap($bootstrap); } // add a cli printer for some output $configuration->addLogger(new Result\PrinterCli($configuration->getVerbose(), $configuration->getColors(), $configuration->getDebug())); return $configuration; }
/** * 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'); } }
/** * Set the cleanup configuration. * * @param \phpbu\App\Configuration\Backup $backup * @param array $json * @throws \phpbu\App\Exception */ protected function setCleanup(Configuration\Backup $backup, array $json) { if (isset($json['cleanup'])) { if (!isset($json['cleanup']['type'])) { throw new Exception('invalid cleanup configuration: type missing'); } $type = $json['cleanup']['type']; $skip = Arr::getValue($json['cleanup'], 'skipOnFailure', true); $options = $this->getOptions($json['cleanup']); $backup->setCleanup(new Configuration\Backup\Cleanup($type, $skip, $options)); } }
/** * (non-PHPDoc) * * @see \phpbu\App\Backup\Sync::setup() * @param array $config * @throws \phpbu\App\Backup\Sync\Exception */ public function setup(array $config) { if (!class_exists('\\Aws\\S3\\S3Client')) { throw new Exception('Amazon SDK not loaded: use composer "aws/aws-sdk-php": "2.7.*" to install'); } if (!Arr::isSetAndNotEmptyString($config, 'key')) { throw new Exception('AWS key is mandatory'); } if (!Arr::isSetAndNotEmptyString($config, 'secret')) { throw new Exception('AWS secret is mandatory'); } if (!Arr::isSetAndNotEmptyString($config, 'bucket')) { throw new Exception('AWS S3 bucket name is mandatory'); } if (!Arr::isSetAndNotEmptyString($config, 'region')) { throw new Exception('AWS S3 region is mandatory'); } if (!Arr::isSetAndNotEmptyString($config, 'path')) { throw new Exception('AWS S3 path / object-key is mandatory'); } $this->key = $config['key']; $this->secret = $config['secret']; $this->bucket = $config['bucket']; $this->region = $config['region']; $this->path = Str::withTrailingSlash(Str::replaceDatePlaceholders($config['path'])); $this->acl = Arr::getValue($config, 'acl', 'private'); }
/** * 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')); }
/** * (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); } }
/** * Get index and type. * * @param array $conf */ protected function setupSourceData(array $conf) { $this->index = Util\Arr::getValue($conf, 'index'); $this->type = Util\Arr::getValue($conf, 'type'); }
/** * Create Swift Smtp Transport. * * @param array $options * @return \Swift_SmtpTransport * @throws \phpbu\App\Exception */ protected function getSmtpTransport(array $options) { if (!isset($options['smtp.host'])) { throw new Exception('option \'smtp.host\' ist missing'); } $host = $options['smtp.host']; $port = Arr::getValue($options, 'smtp.port', 25); $username = Arr::getValue($options, 'smtp.username'); $password = Arr::getValue($options, 'smtp.password'); $encryption = Arr::getValue($options, 'smtp.encryption'); /* @var $transport \Swift_SmtpTransport */ $transport = \Swift_SmtpTransport::newInstance($host, $port); if ($username && $password) { $transport->setUsername($username)->setPassword($password); } if ($encryption) { $transport->setEncryption($encryption); } return $transport; }
/** * Get tables and databases to backup. * * @param array $conf */ protected function setupSourceData(array $conf) { $this->tables = Util\Str::toList(Util\Arr::getValue($conf, 'tables')); $this->databases = Util\Str::toList(Util\Arr::getValue($conf, 'databases')); $this->ignoreTables = Util\Str::toList(Util\Arr::getValue($conf, 'ignoreTables')); $this->structureOnly = Util\Str::toList(Util\Arr::getValue($conf, 'structureOnly')); }
/** * Override configuration settings with command line arguments. * * @param \phpbu\App\Configuration $configuration * @param string $value */ protected function overrideConfigWithArgument(Configuration $configuration, $value) { if (Arr::getValue($this->arguments, $value) === true) { $setter = 'set' . ucfirst($value); $configuration->{$setter}(true); } }
/** * Fetch credential settings. * * @param array $conf */ protected function setupCredentials(array $conf) { $this->host = Util\Arr::getValue($conf, 'host'); $this->user = Util\Arr::getValue($conf, 'user'); $this->password = Util\Arr::getValue($conf, 'password'); $this->authenticationDatabase = Util\Arr::getValue($conf, 'authenticationDatabase'); }
/** * Get tables and databases to backup. * * @param array $conf */ protected function setupSourceData(array $conf) { $this->include = Util\Arr::getValue($conf, 'include'); $this->databases = Util\Str::toList(Util\Arr::getValue($conf, 'databases')); }