Restore.php

This commit is contained in:
fogelito
2023-08-14 20:17:48 +03:00
parent 90e8395578
commit fee17987b0
2 changed files with 20 additions and 14 deletions
+8 -3
View File
@@ -157,7 +157,7 @@ class Backup extends Action
$cmd = 'docker exec ' . $this->xtrabackupContainerId . ' ' . implode(' ', $args);
shell_exec($cmd);
Console::success($cmd);
$stderr = shell_exec('tail -1 ' . $log);
if (!str_contains($stderr, 'completed OK!')) {
@@ -256,7 +256,7 @@ class Backup extends Action
{
$stdout = '';
$stderr = '';
Console::execute('docker exec -i ' . $this->xtrabackupContainerId . ' nproc', '', $stdout, $stderr);
Console::execute('docker exec ' . $this->xtrabackupContainerId . ' nproc', '', $stdout, $stderr);
if (!empty($stderr)) {
Console::error('Error setting processors: ' . $stderr);
Console::exit();
@@ -264,7 +264,12 @@ class Backup extends Action
$processors = str_replace(PHP_EOL, '', $stdout);
$processors = intval($processors);
$processors = $processors === 0 ? 1 : $processors;
if ($processors === 0) {
Console::error('Set Processors Error');
Console::exit();
}
$this->processors = $processors;
}
}
+12 -11
View File
@@ -65,10 +65,10 @@ class Restore extends Action
Console::exit();
}
// if (file_exists($datadir . '/sys') || file_exists($datadir . '/appwrite')) {
// Console::error('Datadir ' . $datadir . ' must be empty!');
// Console::exit();
// }
if (file_exists($datadir . '/sys') || file_exists($datadir . '/appwrite')) {
Console::error('Datadir ' . $datadir . ' must be empty!');
//Console::exit();
}
$this->log('--- Restore Start ' . $id . ' --- ');
$filename = $id . '.xbstream';
@@ -138,14 +138,13 @@ class Restore extends Action
$args = [
'xbstream -x < ' . $file,
'--decompress',
'--parallel=' . $this->processors,
'--parallel=' . intval($this->processors / 2),
'-C ' . $target,
];
$stdout = '';
$stderr = '';
$cmd = 'docker exec -i ' . $this->xtrabackupContainerId . ' ' . implode(' ', $args);
Console::success($cmd);
Console::execute($cmd, '', $stdout, $stderr);
if (!empty($stderr)) {
Console::error('Xbstream Error: ' . $stderr);
@@ -223,9 +222,6 @@ class Restore extends Action
public function checkEnvVariables(): void
{
var_dump(self::getName());
foreach (
[
'_APP_CONNECTIONS_BACKUPS_STORAGE',
@@ -280,7 +276,7 @@ class Restore extends Action
{
$stdout = '';
$stderr = '';
Console::execute('docker exec -i ' . $this->xtrabackupContainerId . ' nproc', '', $stdout, $stderr);
Console::execute('docker exec ' . $this->xtrabackupContainerId . ' nproc', '', $stdout, $stderr);
if (!empty($stderr)) {
Console::error('Error setting processors: ' . $stderr);
Console::exit();
@@ -288,7 +284,12 @@ class Restore extends Action
$processors = str_replace(PHP_EOL, '', $stdout);
$processors = intval($processors);
$processors = $processors === 0 ? 1 : $processors;
if ($processors === 0) {
Console::error('Set Processors Error');
Console::exit();
}
$this->processors = $processors;
}
}