Пример #1
0
 public function testArchivedStoredDump()
 {
     $dumper = m::mock('McCool\\DatabaseBackup\\Dumpers\\DumperInterface');
     $dumper->shouldReceive('dump', 'getOutputFilename');
     $archiver = m::mock('McCool\\DatabaseBackup\\Archivers\\ArchiverInterface');
     $archiver->shouldReceive('setInputFilename', 'archive', 'getOutputFilename');
     $storer = m::mock('McCool\\DatabaseBackup\\Storers\\StorerInterface');
     $storer->shouldReceive('setInputFilename', 'store');
     $backup = new BackupProcedure($dumper);
     $backup->setArchiver($archiver);
     $backup->setStorer($storer);
     $backup->backup();
 }
Пример #2
0
 /**
  * Execure the backup command.
  *
  * @return void
  */
 public function fire()
 {
     $backup = new BackupProcedure($this->getDumper());
     $archiver = $this->getArchiver();
     $storer = $this->getStorer();
     if ($archiver) {
         $backup->setArchiver($archiver);
     }
     if ($storer) {
         $backup->setStorer($storer);
     }
     $backup->backup();
     if ($this->option('cleanup')) {
         $backup->cleanup();
     }
 }
Пример #3
0
 /**
  * Backup DB
  *
  * @return File download
  */
 public function backup()
 {
     // DB info
     $host = Config::get('database.connections.mysql.host');
     $username = Config::get('database.connections.mysql.username');
     $password = Config::get('database.connections.mysql.password');
     $database = Config::get('database.connections.mysql.database');
     // SQL file
     $file = storage_path() . '/backup/' . $database . '.sql';
     // Export
     $shellProcessor = new ShellProcessor(new Process(''));
     $dumper = new MysqlDumper($shellProcessor, $host, 3306, $username, $password, $database, $file);
     $backup = new BackupProcedure($dumper);
     $backup->backup();
     // DL File
     return Response::download($file);
 }