protected function execute(InputInterface $input, OutputInterface $output) { // Database data. $databases = Config::getFile('database'); foreach ($databases as $profile => $data) { $dbs[] = [$profile, $data['type'], $data['database'], $data['user'], $data['host'], $data['port']]; } // Output table. $table = new Table($output); $table->setHeaders(['Profile', 'Type', 'Database', 'Username', 'Server', 'Port'])->setRows($dbs); $table->render(); }
public static function files($directory, $storage, $storage_directory, $compression, $exclude) { try { $file_provider = new BackupFile(); $backup = $file_provider->backup($directory, $storage, $storage_directory, $compression, $exclude); } catch (\Exception $e) { return parent::consoleFormattedError($e->getMessage()); } // Get storage config. $storage_config = Config::getStorage($backup['storage']); // If we get till here, it means there were no exceptions, so the backup process was successful. return " Backup <fg=green>successfully</> saved on <fg=blue>{$backup['storage']}</> (<fg=yellow>{$storage_config['root']}</>) storage\n Backup path: <fg=yellow>{$backup['directory']}/{$backup['file']}</>\n"; }
public static function getFile($file = null) { // Validate configuration. if (Config::validate() && !empty($file)) { $config_path = Config::path(); $config = []; if (!empty($file) && file_exists($config_path . $file . '.yml')) { try { $config = Yaml::parse(file_get_contents($config_path . $file . '.yml')); } catch (ParseException $e) { printf("Unable to parse the YAML string: %s", $e->getMessage()); } } return $config; } return false; }
public function __construct() { // Filesystems $storage_config = Config::getFile('storage'); $this->filesystems = new Filesystems\FilesystemProvider(new BackupManagerConfig($storage_config)); $this->filesystems->add(new Filesystems\LocalFilesystem()); $this->filesystems->add(new Filesystems\Awss3Filesystem()); $this->filesystems->add(new Filesystems\DropboxFilesystem()); $this->filesystems->add(new OVH()); // Databases $db_config = Config::getFile('database'); $this->databases = new Databases\DatabaseProvider(new BackupManagerConfig($db_config)); $this->databases->add(new Databases\MysqlDatabase()); $this->databases->add(new Databases\PostgresqlDatabase()); // Compressors $this->compressors = new Compressors\CompressorProvider(); $this->compressors->add(new Compressors\GzipCompressor()); $this->compressors->add(new Compressors\NullCompressor()); $this->compressors->add(new SevenZip()); $this->compressors->add(new SevenZipNull()); $this->compressors->add(new SevenZipUltra()); // Shell processor. $this->shellProcessor = $this->getShellProcessor(); }