check empty

This commit is contained in:
fogelito
2023-08-09 23:13:52 +03:00
parent 125e388ded
commit b0807da8ee
2 changed files with 10 additions and 7 deletions
+4 -3
View File
@@ -88,12 +88,13 @@ class Backup extends Action
}
} while ($attempts < $max);
$this->xtrabackupContainerId = shell_exec('docker ps -aqf "name=xtrabackup"');
$this->xtrabackupContainerId = str_replace(PHP_EOL, '', $this->xtrabackupContainerId);
if (empty($this->xtrabackupContainerId)) {
$containerId = shell_exec('docker ps -aqf "name=xtrabackup"');
$containerId = str_replace(PHP_EOL, '', $containerId);
if (empty($containerId)) {
Console::error('Xtrabackup Container ID not found');
Console::exit();
}
$this->xtrabackupContainerId = $containerId;
Console::loop(function () {
$this->start();
+6 -4
View File
@@ -21,19 +21,21 @@ class Restore extends Action
protected ?DSN $dsn = null;
protected string $database;
protected ?DOSpaces $s3 = null;
protected string|null $xtrabackupContainerId = null;
protected string $xtrabackupContainerId;
public function __construct()
{
$this->checkEnvVariables();
$this->xtrabackupContainerId = shell_exec('docker ps -aqf "name=xtrabackup"');
$this->xtrabackupContainerId = str_replace(PHP_EOL, '', $this->xtrabackupContainerId);
if (empty($this->xtrabackupContainerId)) {
$containerId = shell_exec('docker ps -aqf "name=xtrabackup"');
$containerId = str_replace(PHP_EOL, '', $containerId);
if (empty($containerId)) {
Console::error('Xtrabackup Container ID not found');
Console::exit();
}
$this->xtrabackupContainerId = $containerId;
$this
->desc('Restore a DB')
->param('id', '', new Text(20), 'The backup identification')