Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

backup mysql-db-list

Batch backup of multiple databases in one instance of MySQL.

Command Format:

peppykeep backup mysql-db-list --request-file <FILE> [--apply] [--config-home <DIR>]

Description

  • --request-file<FILE>: Request file path, supportsjsonandtoml.
  • --apply: really performs the backup; only the summary is output when not imported.
  • --config-home<DIR>: configuration directory. bak.toml still provides MySQL connection parameters, object storage configuration, encryption configuration, and local backup directory.

dry-run example

peppykeep backup mysql-db-list \
  --request-file ./mysql_bak_request.toml \
  --config-home /data/conf/peppykeep/mysql-bak

The output summary will include:

  • RequestFile
  • Instance
  • DbCount
  • Upload
  • LocalCleanup
  • RemoteCleanup
  • Docker

Execution Example

peppykeep backup mysql-db-list \
  --request-file ./mysql_bak_request.toml \
  --config-home /data/conf/peppykeep/mysql-bak \
  --apply

TOML Example

instance_name = "mysql_instance_a"
upload_to_oss = true
remove_older_files = true
remove_older_oss_files = true

[base]
uuid = ""
name = "mysql_bak"
desc = "backup multiple mysql databases"

[[db_config_list]]
db_name = "db_a"
include_table_list = []
exclude_table_list = []

[[db_config_list]]
db_name = "db_b"
include_table_list = []
exclude_table_list = ["large_table_1", "large_table_2"]

JSON Example

{
  "base": {
    "uuid": "",
    "name": "mysql_bak",
    "desc": "backup multiple mysql databases"
  },
  "instance_name": "mysql_instance_a",
  "container": {
    "docker_container_name": "mysql-container-a",
    "docker_cmd_path": "/usr/bin/docker"
  },
  "db_config_list": [
    {
      "db_name": "db_a",
      "include_table_list": [],
      "exclude_table_list": []
    },
    {
      "db_name": "db_b",
      "include_table_list": [],
      "exclude_table_list": [
        "large_table_1",
        "large_table_2"
      ]
    }
  ],
  "upload_to_oss": true,
  "remove_older_files": true,
  "remove_older_oss_files": true
}

Table Filter Rules

  • *: matches any length character
  • ?: matches a single character
  • [abc]: matches one character in the character set
  • [a-z], [0-9]: matches character range

Example:

[[db_config_list]]
db_name = "db_c"
include_table_list = ["user_*", "order_2026??", "log_[0-9][0-9]"]
exclude_table_list = []

exclude_table_list does not take effect when include_table_list is not empty. When the pattern in include_table_list does not match any table, the command reports an error directly.

Behaviour description

  1. Read request-file
  2. Export each database in db_config_list in turn
  3. Package and compress multiple .sql files
  4. Configure to generate encrypted files when encryption is enabled
  5. Upload object store when upload_to_oss = true
  6. Clean up local history files when remove_older_files = true
  7. Clean remote history files when remove_older_oss_files = true