定时备份docker里mysql的数据

标题

 

expire_backup_delete="OFF"
expire_days=3
backup_time=`date +%Y%m%d%H%M`
backup_dir=/home/data/mysql

# 备份指定数据库中数据
docker exec 301520ed7b07 mysqldump -uroot -p123456 leyeoa | gzip > ${backup_dir}/leyeoa_${backup_time}.sql.gz
echo "备份完成"

# 删除过期数据
if [ "$expire_backup_delete" == "ON" ];then
        `find $backup_dir/ -type f -mtime +$expire_days | xargs rm -rf`
        echo "Expired backup data delete complete!"
fi

  

解压gz压缩包

gzip -d FileName.gz

 

设置定时任务

posted @ 2021-07-15 18:11  露天窗  阅读(74)  评论(0编辑  收藏  举报