This repository has been archived by the owner on Feb 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added command that lets you restore the database from previous backup. * Travis test * Bugfix with filename * Added dropbox support for download * Bugfix * Optional * Optional * Throw exception if some parameters are not set
- Loading branch information
Showing
33 changed files
with
1,035 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
namespace Dizda\CloudBackupBundle\Client; | ||
|
||
interface DownloadableClientInterface | ||
{ | ||
/** | ||
* Download lastest backup file. | ||
* | ||
* @return \SplFileInfo | ||
*/ | ||
public function download(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?php | ||
|
||
namespace Dizda\CloudBackupBundle\Command; | ||
|
||
use Dizda\CloudBackupBundle\Manager\RestoreManager; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
class RestoreCommand extends Command | ||
{ | ||
const RETURN_STATUS_SUCCESS = 0; | ||
const RETURN_STATUS_NOT_AVAILABLE = 1; | ||
const RETURN_STATUS_MISSING_FORCE_FLAG = 2; | ||
const RETURN_STATUS_EXCEPTION_OCCURRED = 3; | ||
|
||
/** | ||
* @var bool | ||
*/ | ||
protected $doRestore; | ||
|
||
/** | ||
* @var RestoreManager | ||
*/ | ||
protected $restoreManager; | ||
|
||
/** | ||
* @param boolean $doRestore | ||
* @param RestoreManager $restoreManager | ||
*/ | ||
public function __construct($doRestore, RestoreManager $restoreManager) | ||
{ | ||
$this->doRestore = $doRestore; | ||
$this->restoreManager = $restoreManager; | ||
|
||
parent::__construct(); | ||
} | ||
|
||
/** | ||
* Configure the command. | ||
*/ | ||
protected function configure() | ||
{ | ||
$this | ||
->setName('dizda:backup:restore') | ||
->setDescription('Download latest backup, uncompress and restore.') | ||
->addOption('force', null, InputOption::VALUE_NONE) | ||
; | ||
} | ||
|
||
/** | ||
* @param InputInterface $input | ||
* @param OutputInterface $output | ||
* | ||
* @return int | ||
*/ | ||
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
if (!$this->doRestore) { | ||
$output->writeln('<error>Restore is not available. Enable by setting dizda_cloud_backup.restore: true in config.yml.</error>'); | ||
|
||
return self::RETURN_STATUS_NOT_AVAILABLE; | ||
} | ||
|
||
if (!$input->getOption('force')) { | ||
$output->writeln('<error>Run command with --force to execute.</error>'); | ||
|
||
return self::RETURN_STATUS_MISSING_FORCE_FLAG; | ||
} | ||
|
||
$output->writeln('Restoring backup started'); | ||
|
||
if ($this->restoreManager->execute()) { | ||
$output->writeln('Restoring backup completed'); | ||
|
||
return self::RETURN_STATUS_SUCCESS; | ||
} else { | ||
$output->writeln('<error>Something went wrong</error>'); | ||
|
||
return self::RETURN_STATUS_EXCEPTION_OCCURRED; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace Dizda\CloudBackupBundle\Database; | ||
|
||
interface RestorableDatabaseInterface | ||
{ | ||
/** | ||
* Restore the database with a previous dump | ||
*/ | ||
public function restore(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.