🧨使用mysqldump自动定制备份docker容器中的mysql(shell脚本),并定时删除7天前的备份数据
#!/bin/bash
#Author: YxinMiracle
#Created Time: 2021-10-29 10:34
#Release: 1.0
file_name=`date "+%y-%m-%d[%H:%M:%S]"`
path="/mydata/backup/"
docker exec mysql mysqldump -uxxxxx -pxxxx --databases [bd1 bd2] >> ${path}${file_name}.sql
find $path -mtime +7 -name '*.sql' -exec rm -rf {} \;