Пример #1
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);
 }
 /**
  * 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;
     });
 }
Пример #3
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);
 }
 /**
  * @return void
  */
 private function validateArguments()
 {
     $root = $this->filesystems->getConfig($this->option('source'), 'root');
     $this->info('Just to be sure...');
     $this->info(sprintf('Do you want to restore the backup <comment>%s</comment> from <comment>%s</comment> to database <comment>%s</comment> and decompress it from <comment>%s</comment>?', $root . $this->option('sourcePath'), $this->option('source'), $this->option('database'), $this->option('compression')));
     $this->line('');
     $confirmation = $this->confirm('Are these correct? [Y/n]');
     if (!$confirmation) {
         $this->reaskArguments();
     }
 }
Пример #5
0
 /**
  * @throws \BackupManager\Config\ConfigFieldNotFound
  * @throws \BackupManager\Config\ConfigNotFoundForConnection
  * @return void
  */
 private function validateArguments()
 {
     $root = $this->filesystems->getConfig($this->option('destination'), 'root');
     $this->info('Just to be sure...');
     $this->info(sprintf('Do you want to create a backup of <comment>%s</comment>, store it on <comment>%s</comment> at <comment>%s</comment> and compress it to <comment>%s</comment>?', $this->option('database'), $this->option('destination'), $root . $this->option('destinationPath'), $this->option('compression')));
     $this->line('');
     $confirmation = $this->confirm('Are these correct? [Y/n]');
     if (!$confirmation) {
         $this->reaskArguments();
     }
 }
Пример #6
0
 /**
  * @return void
  */
 private function validateArguments()
 {
     $root = $this->filesystems->getConfig($this->option('source'), 'root');
     $this->info('Just to be sure...');
     $this->info(sprintf('Do you want to list files from <comment>%s</comment> on <comment>%s</comment>?', $root . $this->option('path'), $this->option('source')));
     $this->line('');
     $confirmation = $this->confirm('Are these correct? [Y/n]');
     if (!$confirmation) {
         $this->reaskArguments();
     }
 }
Пример #7
0
 /**
  * @param $name
  * @throws \BackupManager\Config\ConfigFieldNotFound
  * @throws \BackupManager\Config\ConfigNotFoundForConnection
  * @return string
  */
 protected function getRootPath($name)
 {
     $path = $this->filesystems->getConfig($name, 'root');
     return preg_replace('/\\/$/', '', $path);
 }
Пример #8
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);
Пример #9
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);