Skip to content

Commit

Permalink
batch/backupdb supports --only=TABLE
Browse files Browse the repository at this point in the history
  • Loading branch information
kohler committed Feb 27, 2025
1 parent 71c5f2e commit 338b4d4
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions batch/backupdb.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ class BackupDB_Batch {
/** @var bool
* @readonly */
private $pc_only;
/** @var list<string>
* @readonly */
private $only_tables;
/** @var list<string>
* @readonly */
private $my_opts = [];
Expand Down Expand Up @@ -148,9 +151,14 @@ function __construct(Dbl_ConnectionParams $cp, $arg, $getopt = null) {
$this->skip_ephemeral = isset($arg["no-ephemeral"]);
$this->single_transaction = true;
$this->tablespaces = isset($arg["tablespaces"]);
$this->pc_only = isset($arg["pc"]);
$this->count = $arg["count"] ?? 1;

$this->pc_only = isset($arg["pc"]);
$this->only_tables = $arg["only"] ?? [];
if ($this->pc_only && !empty($this->only_tables)) {
$this->throw_error("`--pc` and `--only` conflict");
}

foreach ($arg["-"] ?? [] as $arg) {
if (str_starts_with($arg, "--s3-")) {
$this->throw_error("Bad option `{$arg}`");
Expand Down Expand Up @@ -822,7 +830,7 @@ private function run_streams() {
} else if ($this->pc_only) {
$this->run_pc_only_transfer();
} else {
$this->run_mysqldump_transfer([], []);
$this->run_mysqldump_transfer([], $this->only_tables);
}

if (!empty($this->_checked_tables)) {
Expand Down Expand Up @@ -889,6 +897,7 @@ static function make_args($argv) {
"skip-comments Omit comments",
"tablespaces Include tablespaces",
"check-table[] =TABLE Exit with error if TABLE is not present",
"only[] =TABLE Only include TABLE",
"pc Restrict to PC information",
"output-md5 Write MD5 hash of uncompressed dump to stdout",
"output-sha1 Same for SHA-1 hash",
Expand Down

0 comments on commit 338b4d4

Please sign in to comment.