Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 protected function executeAction(MWP_IncrementalBackup_Database_DumperInterface $dumper, array $tables = array(), array $params = array())
 {
     $path = isset($params['path']) ? $params['path'] : $this->baseDir;
     $this->createDirectory($path);
     $result = array();
     foreach ($tables as $entry) {
         $table = isset($entry['name']) ? $entry['name'] : null;
         $filename = isset($entry['filename']) ? $entry['filename'] : $this->generateFilename($table);
         $pathname = $path . '/' . $filename;
         $realpath = ABSPATH . $pathname;
         try {
             if ($table === null) {
                 throw new RuntimeException('Table name not passed.');
             }
             $this->assertTablesExist(array($table));
             $dumper->dump($table, $realpath);
             $result[] = array('table' => $table, 'pathname' => $pathname, 'realpath' => $realpath, 'url' => site_url() . '/' . $pathname);
         } catch (Exception $e) {
             mwp_logger()->error('Failed dumping table', array('table' => $table, 'filename' => $filename, 'pathname' => $pathname, 'error' => $e->getMessage()));
             $this->cleanDumpedTables($result);
             if ($e instanceof MWP_Worker_Exception) {
                 throw $e;
             }
             throw new MWP_Worker_Exception(MWP_Worker_Exception::BACKUP_DATABASE_FAILED, $e->getMessage(), array('message' => $e->getMessage(), 'line' => $e->getLine(), 'file' => $e->getFile()));
         }
     }
     return $this->createResult(array('tables' => $result));
 }
Ejemplo n.º 2
0
 /**
  * @param MWP_IncrementalBackup_Database_DumperInterface $dumper
  * @param array                                          $tables
  *
  * @return MWP_IncrementalBackup_Model_FetchFilesResult
  */
 protected function dumpToSingleStream(MWP_IncrementalBackup_Database_DumperInterface $dumper, array $tables)
 {
     $stream = $dumper->createStream($tables);
     $file = new MWP_IncrementalBackup_Model_File();
     $file->setPathname('tables.sql');
     $file->setStream($stream);
     $result = new MWP_IncrementalBackup_Model_FetchFilesResult();
     $result->setServerStatistics(MWP_IncrementalBackup_Model_ServerStatistics::factory());
     $result->setFiles(array($file));
     return $result;
 }