您现在的位置是:网站首页> 编程资料编程资料
centos中mysql备份数据库脚本分享_linux shell_
2023-05-26
359人已围观
简介 centos中mysql备份数据库脚本分享_linux shell_
复制代码 代码如下:
#!/bin/bash
#backup mysql data
DBDIR=/data/mysql
BACKDIR=/data/bak/mysql
TIME=`date -d "today" +%F`
DB=$(ls -p $DBDIR | grep / |tr -d / | grep -Ev 'information_schema|performance_schema|mysql|test')
/etc/init.d/mysqld stop
if [ -d $BACKDIR ]
then
echo "OK!"
else
mkdir -p $BACKDIR
fi
cd $DBDIR
for i in $DB
do
tar czf $BACKDIR/$i\_db\_$TIME.tar.gz $i
done
/etc/init.d/mysqld start
find $BACKDIR -name "*.tar.gz" -type f -mtime +15 -exec rm {} \; >/dev/null 2>&1
您可能感兴趣的文章:
相关内容
- shell中删除文件中重复行的方法_linux shell_
- shell替换文件中的文件路径脚本分享_linux shell_
- shell脚本操作oracle删除表空间、创建表空间、删除用户_linux shell_
- shell对比文件内容脚本分享_linux shell_
- shell使用mysqld_multi自动做多实例从库脚本_linux shell_
- 使用shell检查并修复mysql数据库表的脚本_linux shell_
- 定时导出mysql本地数据替换远程数据库数据脚本分享_linux shell_
- svn服务器启动和svn服务器重启、停止等操作脚本分享_linux shell_
- 25个好用的Shell脚本常用命令分享_linux shell_
- Shell脚本监控服务器在线状态和邮件报警的方法_linux shell_
