mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Exec by id
This commit is contained in:
@@ -23,6 +23,7 @@ class Backup extends Action
|
||||
protected ?DSN $dsn = null;
|
||||
protected ?string $database = null;
|
||||
protected ?DOSpaces $s3 = null;
|
||||
protected string $xtrabackupContainerId;
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
@@ -87,6 +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)) {
|
||||
Console::error('Xtrabackup Container ID not found');
|
||||
Console::exit();
|
||||
}
|
||||
|
||||
Console::loop(function () {
|
||||
$this->start();
|
||||
}, self::BACKUP_INTERVAL_SECONDS);
|
||||
@@ -148,7 +156,7 @@ class Backup extends Action
|
||||
'2> ' . $logfile,
|
||||
];
|
||||
|
||||
$cmd = 'docker exec xtrabackup ' . implode(' ', $args);
|
||||
$cmd = 'docker exec ' . $this->xtrabackupContainerId . ' ' . implode(' ', $args);
|
||||
self::log($cmd);
|
||||
shell_exec($cmd);
|
||||
|
||||
|
||||
@@ -21,11 +21,19 @@ class Restore extends Action
|
||||
protected ?DSN $dsn = null;
|
||||
protected string $database;
|
||||
protected ?DOSpaces $s3 = null;
|
||||
protected string|null $xtrabackupContainerId = null;
|
||||
|
||||
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)) {
|
||||
Console::error('Xtrabackup Container ID not found');
|
||||
Console::exit();
|
||||
}
|
||||
|
||||
$this
|
||||
->desc('Restore a DB')
|
||||
->param('id', '', new Text(20), 'The backup identification')
|
||||
@@ -166,7 +174,7 @@ class Restore extends Action
|
||||
'2> ' . $logfile,
|
||||
];
|
||||
|
||||
$cmd = 'docker exec xtrabackup ' . implode(' ', $args);
|
||||
$cmd = 'docker exec ' . $this->xtrabackupContainerId . ' ' . implode(' ', $args);
|
||||
$this->log($cmd);
|
||||
shell_exec($cmd);
|
||||
|
||||
@@ -199,7 +207,7 @@ class Restore extends Action
|
||||
'2> ' . $logfile,
|
||||
];
|
||||
|
||||
$cmd = 'docker exec xtrabackup ' . implode(' ', $args);
|
||||
$cmd = 'docker exec ' . $this->xtrabackupContainerId . ' ' . implode(' ', $args);
|
||||
$this->log($cmd);
|
||||
shell_exec($cmd);
|
||||
|
||||
@@ -234,7 +242,7 @@ class Restore extends Action
|
||||
'2> ' . $logfile,
|
||||
];
|
||||
|
||||
$cmd = 'docker exec xtrabackup ' . implode(' ', $args);
|
||||
$cmd = 'docker exec ' . $this->xtrabackupContainerId . ' ' . implode(' ', $args);
|
||||
$this->log($cmd);
|
||||
shell_exec($cmd);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user