#!/bin/bash
date=`date +%Y%m%d`
day=`date +%H`
day1=`date -d "10 days ago" +%Y%m%d`
mkdir -p /home/data_backup/$date/$day
mysqldump -uroot -pchb2004 --all-database | gzip > /home/data_backup/$date/$day/mysql.sql.gz
date=`date +%Y%m%d`
day=`date +%H`
day1=`date -d "10 days ago" +%Y%m%d`
mkdir -p /home/data_backup/$date/$day
mysqldump -uroot -pchb2004 --all-database | gzip > /home/data_backup/$date/$day/mysql.sql.gz
rm -rf /home/data_backup/$day1
本文转自 zl1030 51CTO博客,原文链接:http://blog.51cto.com/zl1030/1558445