Skip to content
This repository has been archived by the owner on Feb 3, 2022. It is now read-only.

Commit

Permalink
Fixes #24: Remove magerun db:dump command usage.
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbyshaw committed Dec 18, 2015
1 parent 28fa9ba commit c4ce4cc
Showing 1 changed file with 2 additions and 36 deletions.
38 changes: 2 additions & 36 deletions src/Meanbee/Magedbm/Command/PutCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,49 +198,15 @@ protected function cleanUp()
}

/**
* Create database backup in tmp directory.
* Use magerun db:dump if available. Otherwise use php alternative if exec not available.
* Database export without using exec.
*
* @param InputInterface $input
* @param OutputInterface $output
*
* @throws \Exception
*/
private function createBackup(InputInterface $input, OutputInterface $output)
{
$magerun = $this->getMagerun();
$filePath = $this->getFilePath($input);

try {
/** @var \N98\Magento\Command\Database\DumpCommand $dumpCommand */
$dumpCommand = $magerun->find("db:dump");

$stripOptions = $input->getOption('strip') ? : '@development';
$dumpInput = new ArrayInput(array(
'filename' => $filePath,
'--strip' => $stripOptions,
'--compression' => 'gzip',
));

if ($dumpCommand->run($dumpInput, $output)) {
throw new \Exception("magerun db:dump failed to create backup..");
}
} catch (\InvalidArgumentException $e) {
$this->createBackupWithoutExec($input, $output);

$output->writeln('<info>Finished</info>');
}
}

/**
* PHP alternative to dump database without exec
*
* @param InputInterface $input
* @param OutputInterface $output
* @throws \Exception
*/
private function createBackupWithoutExec(InputInterface $input, OutputInterface $output)
{
// Use Magerun for getting DB details
$magerun = $this->getMagerun();
$filePath = $this->getFilePath($input);

Expand Down

0 comments on commit c4ce4cc

Please sign in to comment.