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 = "/tmp/logs/peppykeep"
local_bak_home = "/tmp/backup/peppykeep"
local_tmp_home = "/tmp/.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 = "/usr/local/bin/mysqldump"
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 ~/.peppykeep/conf/mysql_bak_request.toml \
--config-home ~/.peppykeep/conf
When the pre-test is successful, the output is as follows:
=== Dry Run ===
Action : backup mysql-db-list
RequestFile : /path/to/user/.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.
| Field | Description |
|---|---|
| Action | Pin to backup mysql-db-list |
| RequestFile | Request file path |
| Instance | corresponding to instance_name |
| DbCount | Number of libraries in db_config_list |
| Upload | Corresponds to upload_to_oss |
| LocalCleanup | corresponds to remove_older_files |
| RemoteCleanup | corresponds to remove_older_oss_files |
| Docker | Container backup configuration; <none> when not configured |
| Next | Formal execution after adding `--apply’ |
Perform a backup
peppykeep backup mysql-db-list \
--request-file ~/.peppykeep/conf/mysql_bak_request.toml \
--apply \
--config-home ~/.peppykeep/conf
Example output on success:
=== Completed ===
Action : backup mysql-db-list
RequestFile : /path/to/user/.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 说明。