예제 #1
0
 protected function _syncDb()
 {
     $mediator = new Garp_Content_Db_Mediator($this->_sourceEnv, $this->_targetEnv);
     $source = $mediator->getSource();
     $target = $mediator->getTarget();
     $this->_enableHighMemory();
     $progress = Garp_Cli_Ui_ProgressBar::getInstance();
     $progress->init(3);
     //  1.
     $progress->display("Backing up");
     $target->backup();
     $progress->advance();
     //  2.
     $progress->display("Fetching data");
     $dump = $source->fetchDump();
     $progress->advance();
     //  3.
     $progress->display("Injecting data");
     $target->restore($dump);
     $progress->advance();
     $progress->display("√ Database in sync");
 }
예제 #2
0
 public function restoreDatabase()
 {
     // @todo Assuming CLI environment, better to use some kind of abstract output writer
     Garp_Cli::lineOut('Restoring database...');
     $sourceEnv = $this->_getGumballConfig('sourceDbEnvironment');
     if (!$sourceEnv) {
         throw new Garp_Gumball_Exception_SourceEnvNotConfigured();
     }
     $mediator = new Garp_Content_Db_Mediator($sourceEnv, APPLICATION_ENV);
     $target = $mediator->getTarget();
     $dump = file_get_contents(APPLICATION_PATH . '/data/sql/' . basename($this->_getDataDumpLocation()));
     $target->restore($dump);
 }