Ejemplo n.º 1
0
 /**
  * Register the compressor provider.
  *
  * @return void
  */
 private function registerCompressorProvider()
 {
     $this->app->bind(\BackupManager\Compressors\CompressorProvider::class, function () {
         $provider = new Compressors\CompressorProvider();
         $provider->add(new Compressors\GzipCompressor());
         $provider->add(new Compressors\NullCompressor());
         return $provider;
     });
 }
Ejemplo n.º 2
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);
 }
Ejemplo n.º 3
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);