下载 TiDB 企业版工具集 (Linux)
1、下载 tool 压缩包:
wget http://download.pingcap.org/tidb-enterprise-tools-latest-linux-amd64.tar.gz &&
wget http://download.pingcap.org/tidb-enterprise-tools-latest-linux-amd64.sha256
2、检查文件完整性,返回 ok 则正确:
sha256sum -c tidb-enterprise-tools-latest-linux-amd64.sha256
3、解开压缩包:
tar -xzf tidb-enterprise-tools-latest-linux-amd64.tar.gz &&
cd tidb-enterprise-tools-latest-linux-amd64
4、使用案例
定时备份数据库数据(以uat2_*开头的数据库,-x正则表达式)
#!/bin/bash
## 所有路径都要写绝对路径
# 执行数据库备份(/home/backup——mydumper工具目录)(/home/backup/mysql_uat51_backup_$(date +%Y%m%d)/——要备份的文件名字)
/home/backup/mydumper -h IP地址 -u root -p 密码 -P 3306 -t 16 -F 64 -x uat2_* --skip-tz-utc -o /home/backup/mysql_uat51_backup_$(date +%Y%m%d)/
# 删除5天前的备份文件(/home/backup备份文件路径)
rm -rf /home/backup/mysql_uat51_backup_$(date -d "5 days ago" +%Y%m%d)/
# 添加到定时任务命令crontab -e
使用语句
定时每天凌晨一点
0 1 * * * /home/backup/mysql_uat51_backup.sh
* * * * *
- - - - -
| | | | |
| | | | +----- 星期中星期几 (0 - 7) (星期天 为0)
| | | +---------- 月份 (1 - 12)
| | +--------------- 一个月中的第几天 (1 - 31)
| +-------------------- 小时 (0 - 23)
+------------------------- 分钟 (0 - 59)