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

Batch Backup Database

Multiple libraries need to be backed up at once under the same MySQL instance, and the filtering rules of each library table may be different. Use mysql_bak_request.toml with backup mysql-db-list.

Backup to local

enforce_provisioning_action

1. bak.toml — need to include MySQL connection and local path (bak_type has no effect on mysql-db-list but [mysql] is required):

[public]
bak_location_type = "local"
history_bak_num = 3
log_level = "DEBUG"
log_dir = "C:\\Users\\admin\\AppData\\Local\\Temp\\my_test_peppykeep\\logs"
local_bak_home = "C:\\Users\\admin\\AppData\\Local\\Temp\\my_test_peppykeep\\backup"
local_tmp_home = "C:\\Users\\admin\\AppData\\Local\\Temp\\my_test_peppykeep\\.tmp"
max_bak_queue_size = 1

[mysql]
mysql_ip = "127.0.0.1"
mysql_port = 3306
mysql_user_name = "root"
mysql_pwd = "root"
mysqldump_path = "C:\\Program Files\\MySQL\\MySQL Server 8.0\\bin\\mysqldump.exe"
skip_ssl = true

完整参数见 bak.toml 配置说明。

2. mysql_bak_request.toml

instance_name = "test_717_file11111"
upload_to_oss = false
remove_older_files = true
remove_older_oss_files = false   # Must be false when upload_to_oss is false

[base]
uuid = ""
name = "batch-mysql-task"
desc = "backup multiple databases"

[[db_config_list]]
db_name = "7.12database1"
include_table_list = []
exclude_table_list = []

[[db_config_list]]
db_name = "7.12database2"
include_table_list = []
exclude_table_list = []

See mysql_bak_request.toml for details.

Perform the preliminary checks: §.

peppykeep backup mysql-db-list ^
  --request-file %USERPROFILE%\.peppykeep\conf\mysql_bak_request.toml ^
  --config-home %USERPROFILE%\.peppykeep\conf

When the pre-test is successful, the output is as follows:

=== Dry Run ===
Action        : backup mysql-db-list
RequestFile   : C:\Users\admin\.peppykeep\conf\mysql_bak_request.toml
Instance      : test_717_file11111
DbCount       : 2
Upload        : false
LocalCleanup  : true
RemoteCleanup : false
Docker        : <none>
Next          : Re-run with --apply to execute.
FieldDescription
ActionPin to backup mysql-db-list
RequestFileRequest file path
Instancecorresponding to instance_name
DbCountNumber of libraries in db_config_list
UploadCorresponds to upload_to_oss
LocalCleanupcorresponds to remove_older_files
RemoteCleanupcorresponds to remove_older_oss_files
DockerContainer backup configuration; <none> when not configured
NextFormal execution after adding `--apply’

Perform a backup

peppykeep backup mysql-db-list ^
  --request-file %USERPROFILE%\.peppykeep\conf\mysql_bak_request.toml ^
  --apply ^
  --config-home %USERPROFILE%\.peppykeep\conf

Example output on success:

=== Completed ===
Action        : backup mysql-db-list
RequestFile   : C:\Users\admin\.peppykeep\conf\mysql_bak_request.toml
Instance      : test_717_file11111
DbCount       : 2
Upload        : false
LocalCleanup  : true
RemoteCleanup : false
Docker        : <none>
Status        : Command completed successfully.

Backup to Object Storage

在 mysql_bak_request.toml 中设置 upload_to_oss = true,并在 bak.toml 配置 [object_storage]。上传与保留策略见 备份文件上传对象存储 与 bak.toml 说明。

Order Details Reference