Skip to content

Commit

Permalink
Adds in the functionality to delete db backups. (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
typhonius authored Apr 22, 2020
1 parent 20eb332 commit b043a32
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 41 deletions.
53 changes: 12 additions & 41 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions src/Commands/DbBackupCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,4 +266,30 @@ function (
$this->writeln(PHP_EOL);
$this->say(sprintf('Database backup downloaded to %s', $location));
}

/**
* Deletes a database backup.
*
* @param string $uuid
* @param string $environment
* @param string $dbName
* @param int $backupId
*
* @command database:backup:delete
* @aliases db:backup:delete
*/
public function dbBackupDelete(DatabaseBackups $databaseBackupsAdapter, $uuid, $environment, $dbName, $backupId)
{
$environment = $this->cloudapiService->getEnvironment($uuid, $environment);

if (
$this->confirm(
sprintf('Are you sure you want to delete backup id %s in %s?', $backupId, $environment->label)
)
) {
$this->say(sprintf('Deleting backup %s to %s on %s', $backupId, $dbName, $environment->label));
$response = $databaseBackupsAdapter->delete($environment->uuid, $dbName, $backupId);
$this->waitForNotification($response);
}
}
}
3 changes: 3 additions & 0 deletions tests/AcquiaCliTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,9 @@ public static function getFixtureMap()
'get' => 'Logs/downloadLog.dat',
'post' => 'Logs/createLogSnapshot.json'
],
'/environments/24-a47ac10b-58cc-4372-a567-0e02b2c3d470/databases/dbName/backups/1234' => [
'delete' => 'DatabaseBackups/deleteDatabaseBackup.json'
],
'/ides/215824ff-272a-4a8c-9027-df32ed1d68a9' => [
'delete' => 'Ides/deleteIde.json'
],
Expand Down
4 changes: 4 additions & 0 deletions tests/Commands/DbBackupCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ public function dbBackupProvider()
['database:backup:link', 'devcloud:devcloud2', 'dev', 'dbName', '1234'],
$dbLink . PHP_EOL
],
[
['database:backup:delete', 'devcloud:devcloud2', 'dev', 'dbName', '1234'],
'> Deleting backup 1234 to dbName on Dev' . PHP_EOL
],
];
}
}

0 comments on commit b043a32

Please sign in to comment.