Пример #1
0
 /**
  * Register the database provider.
  *
  * @return void
  */
 private function registerDatabaseProvider()
 {
     $this->app->bind(\BackupManager\Databases\DatabaseProvider::class, function ($app) {
         $provider = new Databases\DatabaseProvider($this->getDatabaseConfig($app['config']['database.connections']));
         $provider->add(new Databases\MysqlDatabase());
         $provider->add(new Databases\PostgresqlDatabase());
         return $provider;
     });
 }
Пример #2
0
 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);
 }
 /**
  *
  */
 private function askDatabase()
 {
     $providers = $this->databases->getAvailableProviders();
     $formatted = implode(', ', $providers);
     $this->info("Available database connections: <comment>{$formatted}</comment>");
     $database = $this->autocomplete("From which database connection you want to restore?", $providers);
     $this->input->setOption('database', $database);
 }
Пример #4
0
 /**
  * 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);
 }
Пример #5
0
<?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);
Пример #6
0
<?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);