#!/bin/bash BACK_DIR=/data/Mysql_backup HOST=192.168.10.100 USER=node PASSWord=a12gd DATABASES=(
#!/bin/bash
BACK_DIR=/data/Mysql_backup
HOST=192.168.10.100
USER=node
PASSWord=a12gd
DATABASES=(
node
Gobe
)
BEGIN_TIME=`date '+%F %T'`
BEGIN_TIME_TIMESTAMP=`date '+%s'`
for database in ${DATABASES[*]};do
mysqldump -h${HOST} -u${USER} -p${PASSWORD} --single-transaction --master-data=2 -B $database > ${BACK_DIR}/${database}_`date +%F_%H-%M-%S`.sql
gzip -1 ${BACK_DIR}/*.sql
done
END_TIME_TIMESTAMP=`date '+%s'`
echo "备份开始时间:${BEGIN_TIME},总耗时$((${END_TIME_TIMESTAMP} - ${BEGIN_TIME_TIMESTAMP}))秒!" >> ${BACK_DIR}/backup.log
find ${BACK_DIR}/*.gz -mtime +6 | xargs rm -f
结合任务计划执行:
00 00 * * * /data/mysql_backup/backup.sh
--结束END--
本文标题: mysql或者mariadb备份脚本
本文链接: https://lsjlt.com/news/39706.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-10-23
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0