From 314655ad02a2f8c9c43f76d3b53facd567b33e1e Mon Sep 17 00:00:00 2001 From: fogelito Date: Tue, 12 Sep 2023 19:06:33 +0300 Subject: [PATCH] tar when using lz4? --- src/Appwrite/Platform/Tasks/Backup.php | 17 +++++++++++++---- src/Appwrite/Platform/Tasks/Restore.php | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/Appwrite/Platform/Tasks/Backup.php b/src/Appwrite/Platform/Tasks/Backup.php index 60488ff03e..1c060d15b5 100644 --- a/src/Appwrite/Platform/Tasks/Backup.php +++ b/src/Appwrite/Platform/Tasks/Backup.php @@ -169,17 +169,19 @@ class Backup extends Action '--safe-slave-backup', // https://docs.percona.com/percona-xtrabackup/8.0/make-backup-in-replication-env.html '--safe-slave-backup-timeout=300', '--check-privileges', // checks if Percona XtraBackup has all the required privileges. - '--target-dir=' . self::BACKUPS_PATH, - '--compress=' . self::COMPRESS_ALGORITHM, - '--compress-threads=' . intval($this->processors / 2), + '--target-dir=./', + //'--compress=' . self::COMPRESS_ALGORITHM, + '--compress=lz4', + '--compress-threads=' . $this->processors, '--parallel=' . $this->processors, '> ' . $file, '2> ' . $log, ]; $cmd = 'docker exec ' . $this->xtrabackupContainerId . ' ' . implode(' ', $args); - shell_exec($cmd); Console::success($cmd); + shell_exec($cmd); + $stderr = shell_exec('tail -1 ' . $log); if (!str_contains($stderr, 'completed OK!')) { @@ -190,6 +192,13 @@ class Backup extends Action if (!unlink($log)) { throw new Exception('Error deleting: ' . $log); } + + // tar if using lz4... +// $tar = basename($this->filename, '.xbstream') . '.tar.gz'; +// $cmd = 'cd ' . $target . ' && tar zcf ' . $tar . ' ' . $this->filename . ' && cd ' . getcwd(); +// console::success($cmd); +// shell_exec($cmd); + } /** diff --git a/src/Appwrite/Platform/Tasks/Restore.php b/src/Appwrite/Platform/Tasks/Restore.php index 08c551b9ba..544229763e 100644 --- a/src/Appwrite/Platform/Tasks/Restore.php +++ b/src/Appwrite/Platform/Tasks/Restore.php @@ -60,7 +60,7 @@ class Restore extends Action if (file_exists($datadir . '/sys') || file_exists($datadir . '/appwrite')) { Console::error('Datadir ' . $datadir . ' must be empty!'); - //Console::exit(); + Console::exit(); } $this->log('--- Restore Start ' . $id . ' --- ');