From 645d55c5fae20543cce2a4d5d88e3d927fee89ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20Wittmann=20=E2=80=93=20Gestaltung=20=26=20Entwicklu?= =?UTF-8?q?ng?= Date: Tue, 26 Nov 2024 17:44:51 +0100 Subject: [PATCH] add option --ignoretables to BackupCommand.php --- src/Command/BackupCommand.php | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/Command/BackupCommand.php b/src/Command/BackupCommand.php index 152a11b..6a937ea 100755 --- a/src/Command/BackupCommand.php +++ b/src/Command/BackupCommand.php @@ -50,6 +50,12 @@ protected function configure() 'c', InputOption::VALUE_NONE, 'When specified, resulting backup file will be gzip compressed.' + ) + ->addOption( + 'ignoretables', + 'ignore', + InputArgument::OPTIONAL, + 'When specified, the tables are ignored. Separate multiple tables with commas.' ); } @@ -132,9 +138,18 @@ protected function execute(InputInterface $input, OutputInterface $output) $tablespaces = $input->getOption('no-tablespaces') ? ' --no-tablespaces' : ''; $gzip = $input->getOption('compress') ? '| gzip - ' : ''; - - exec("mysqldump{$tablespaces} -u {$database_user} {$password_parameter} -h {$database_server} {$dbase} {$gzip}> {$targetFile} "); - + + $ignoretables = $input->getOption('ignoretables'); + $ignoretables_parameter = ''; + if ($ignoretables) { + $ignoretables_parameters = []; + foreach (explode(',', $ignoretables) as $tablename) { + $ignoretables_parameters[] = '--ignore-table=' . $dbase . '.' . $tablename; + } + $ignoretables_parameter = implode(' ', $ignoretables_parameters); + } + + exec("mysqldump{$tablespaces} -u {$database_user} {$password_parameter} -h {$database_server} {$dbase} {$ignoretables_parameter} {$gzip}> {$targetFile} "); return 0; }