From b0807da8ee36384f4bc207198bc00a2d08a10fd4 Mon Sep 17 00:00:00 2001 From: fogelito Date: Wed, 9 Aug 2023 23:13:52 +0300 Subject: [PATCH] check empty --- src/Appwrite/Platform/Tasks/Backup.php | 7 ++++--- src/Appwrite/Platform/Tasks/Restore.php | 10 ++++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/Appwrite/Platform/Tasks/Backup.php b/src/Appwrite/Platform/Tasks/Backup.php index 4e1746bcf5..1ace0e9657 100644 --- a/src/Appwrite/Platform/Tasks/Backup.php +++ b/src/Appwrite/Platform/Tasks/Backup.php @@ -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(); diff --git a/src/Appwrite/Platform/Tasks/Restore.php b/src/Appwrite/Platform/Tasks/Restore.php index 52e348e3a9..5f0737c30d 100644 --- a/src/Appwrite/Platform/Tasks/Restore.php +++ b/src/Appwrite/Platform/Tasks/Restore.php @@ -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')