protected function getManagerForDatabase($database, $target) { $config = (require 'config/database.php'); $config['target']['database'] = $database; $databases = new DatabaseProvider(new Config($config)); $databases->add(new MysqlDatabase()); $fileConfig = (require 'config/storage.php'); $fileConfig[$target]['root'] .= $database . '/' . date('Y') . '/' . date('m') . '/' . date('d') . '_' . uniqid(); $filesystem = new FilesystemProvider(new Config($fileConfig)); $filesystem->add(new LocalFilesystem()); $filesystem->add(new Awss3Filesystem()); return new Manager($filesystem, $databases, $this->compressors); }
/** * Register the filesystem provider. * * @return void */ private function registerFilesystemProvider() { $this->app->bind(\BackupManager\Filesystems\FilesystemProvider::class, function ($app) { $provider = new Filesystems\FilesystemProvider(new Config($app['config']['backup-manager'])); $provider->add(new Filesystems\Awss3Filesystem()); $provider->add(new Filesystems\GcsFilesystem()); $provider->add(new Filesystems\DropboxFilesystem()); $provider->add(new Filesystems\FtpFilesystem()); $provider->add(new Filesystems\LocalFilesystem()); $provider->add(new Filesystems\RackspaceFilesystem()); $provider->add(new Filesystems\SftpFilesystem()); return $provider; }); }
/** * Process single backup job. * * @param DatabaseContract $database * @param string $namespace */ private function instance(DatabaseContract $database, $namespace = '') { $file = $this->workingDir . '/' . $database->fileName(); if (is_file($file)) { unlink($file); } $filesystems = new Filesystems\FilesystemProvider($this->fileSystemConfig()); $filesystems->add(new Filesystems\LocalFilesystem()); $databases = new Databases\DatabaseProvider($this->databaseConfig($database)); $databases->add(new Databases\MysqlDatabase()); $databases->add(new Databases\PostgresqlDatabase()); $compressors = new Compressors\CompressorProvider(); $compressors->add(new Compressors\NullCompressor()); $manager = new Manager($filesystems, $databases, $compressors); $manager->makeBackup()->run('config', [new Destination('local', $database->fileName())], 'null'); $this->backup->addToCollection(['name' => $database->fileName(), 'path' => $file], $namespace); $this->backup->addToRemoval($file); }
<?php // path to composer autoloader require '../../vendor/autoload.php'; use BackupManager\Config\Config; use BackupManager\Filesystems; use BackupManager\Databases; use BackupManager\Compressors; use BackupManager\Manager; // build providers $filesystems = new Filesystems\FilesystemProvider(Config::fromPhpFile('config/storage.php')); $filesystems->add(new Filesystems\Awss3Filesystem()); $filesystems->add(new Filesystems\GcsFilesystem()); $filesystems->add(new Filesystems\DropboxFilesystem()); $filesystems->add(new Filesystems\FtpFilesystem()); $filesystems->add(new Filesystems\LocalFilesystem()); $filesystems->add(new Filesystems\RackspaceFilesystem()); $filesystems->add(new Filesystems\SftpFilesystem()); $databases = new Databases\DatabaseProvider(Config::fromPhpFile('config/database.php')); $databases->add(new Databases\MysqlDatabase()); $databases->add(new Databases\PostgresqlDatabase()); $compressors = new Compressors\CompressorProvider(); $compressors->add(new Compressors\GzipCompressor()); $compressors->add(new Compressors\NullCompressor()); // build manager return new Manager($filesystems, $databases, $compressors);
<?php // path to composer autoloader require 'vendor/autoload.php'; use BackupManager\Config\Config; use BackupManager\Filesystems; use BackupManager\Databases; use BackupManager\Compressors; use BackupManager\Manager; // build providers $filesystems = new Filesystems\FilesystemProvider(Config::fromPhpFile('config/storage.php')); $filesystems->add(new Filesystems\Awss3Filesystem()); $filesystems->add(new Filesystems\LocalFilesystem()); $databases = new Databases\DatabaseProvider(Config::fromPhpFile('config/database.php')); $databases->add(new Databases\MysqlDatabase()); $compressors = new Compressors\CompressorProvider(); $compressors->add(new Compressors\GzipCompressor()); $compressors->add(new Compressors\NullCompressor()); // build manager return new Manager($filesystems, $databases, $compressors);