mysql备份脚本 发表于 2018-10-23123456789101112131415161718#!/bin/bash#定时删除过期备份back_path=/home/data/mysql_backupcd $back_pathcurrent_date=`date +%Y%m%d`current_date_stamp=`date -d "$current_date" +%s`dele_date_stamp=$(($current_date_stamp-2592000))echo $dele_date_stampecho "************"for filename in `ls $back_path `;do file_time_stamp=`date -d "$filename" +%s` if [ $file_time_stamp -lt $dele_date_stamp ] ; then rm -rf $back_path/$filename echo "delete $filename" fidone123456789101112131415#!/bin/bash#定时备份数据库USER=rootexport password=123456back_path=/home/data/mysql_backupdate=`date +%Y%m%d`filename=`date +%Y%m%d-%H`mkdir -p $back_path/$date >/dev/null 2>&1mysqldump -u$USER -p$password -A --opt -F --single-transaction > $back_path/$date/$filename.sql# 0 */1 * * * /root/mysql_dump.sh >/dev/null 2>&10 */1 * * * /root/back_script/mysql_dump.sh >/dev/null 2>&10 */1 * * * /root/back_script/delete_expire_file.sh >/dev/null 2>&1坚持原创技术分享,您的支持将鼓励我继续创作!打赏微信支付支付宝