public function AcquiaContentHubPurgeCommands::contenthubRestore in Acquia Content Hub 8.2
Restores the backup taken by a previous execution of the "purge" command.
WARNING! Be VERY careful when using this command. This destructive command requires elevated keys. By restoring a backup you will delete all the existing entities in your subscription.
@command acquia:contenthub-restore @aliases ach-restore,acquia-contenthub-restore
Parameters
string $api: The API key.
string $secret: The (optional) string secret key.
Throws
\Exception
File
- src/
Commands/ AcquiaContentHubPurgeCommands.php, line 153
Class
- AcquiaContentHubPurgeCommands
- Drush commands for purging Acquia Content Hub.
Namespace
Drupal\acquia_contenthub\CommandsCode
public function contenthubRestore($api, $secret) {
$warning_message = "Are you sure you want to RESTORE the latest backup taken after purging your Content Hub Subscription?\n" . "*************************************************************************************\n" . "PROCEED WITH CAUTION. THIS ACTION WILL ELIMINATE ALL EXISTING ENTITIES IN YOUR CONTENT HUB SUBSCRIPTION.\n" . "This restore command should only be used after an accidental purge event has taken place *and* completed. This will attempt to restore\n" . "from the last purge-generated backup. In the event this fails, you will need to republish your content to Content Hub.\n For more information, check https://docs.acquia.com/content-hub.\n" . "*************************************************************************************\n" . "Are you sure you want to proceed?\n";
if ($this
->io()
->confirm($warning_message)) {
if (!empty($api) && !empty($secret)) {
$client = $this
->resetConnection($this->clientFactory
->getClient(), $api, $secret);
}
else {
$client = $this->clientFactory
->getClient();
}
// Execute the 'restore' command.
if (!$client) {
throw new \Exception(dt('Error trying to connect to the Content Hub. Make sure this site is registered to Content hub.'));
}
$response = $client
->restore();
if (isset($response['success']) && $response['success'] === TRUE) {
$this
->output()
->writeln("Your Subscription is being restored. All clients who have registered to received webhooks will be notified with a reindex webhook when the restore process has been completed.\n");
}
else {
throw new \Exception(dt("Error trying to restore your subscription from a backup copy. You might require elevated keys to perform this operation."));
}
}
}