一個簡單mysql 備份策略 。
#!/bin/sh
BACKTIME=`date +%Y%m%d`
DELTIME=`date +%Y%m%d -d -7day`
echo "===================================$BACKTIME==================================="
if [ ! -d /backup/bak_mysqldata/$BACKTIME ]
then
mkdir /backup/bak_mysqldata/$BACKTIME
fi
cd /backup/bak_mysqldata/$BACKTIME
#if [ ! -f /backup/bak_mysqldata/$BACKTIME/blog_db.sql ]
#then
# bgdt=`date +%H:%M:%S`
# /usr/local/mysql/bin/mysqldump blog_db > /backup/bak_mysqldata/$BACKTIME/blog_db.sql
# eddt=`date +%H:%M:%S`
# echo -e "$bgdt\tStart to dumping blog_db!"
# echo -e "$eddt\tblog_db database dump finish!!!"
#fi
#if [ ! -f /backup/bak_mysqldata/$BACKTIME/dw_data_center.sql ]
#then
# bgdt=`date +%H:%M:%S`
# /usr/local/mysql/bin/mysqldump dw_data_center > /backup/bak_mysqldata/$BACKTIME/dw_data_center.sql
# eddt=`date +%H:%M:%S`
# echo -e "$bgdt\tStart to dumping dw_data_center!"
# echo -e "$eddt\tdw_data_center database dump finish!!!"
#fi
if [ ! -f /backup/bak_mysqldata/$BACKTIME/dwnews_new_adsr1.sql ]
then
bgdt=`date +%H:%M:%S`
/usr/local/mysql/bin/mysqldump dwnews_new_adsr1 > /backup/bak_mysqldata/$BACKTIME/dwnews_new_adsr1.sql
eddt=`date +%H:%M:%S`
echo -e "$bgdt\tStart to dumping dwnews_new_adsr1!"
echo -e "$eddt\tdwnews_new_adsr1 database dump finish!!!"
fi
if [ ! -f /backup/bak_mysqldata/$BACKTIME/dwnews_new_adsr2.sql ]
then
bgdt=`date +%H:%M:%S`
/usr/local/mysql/bin/mysqldump dwnews_new_adsr2 > /backup/bak_mysqldata/$BACKTIME/dwnews_new_adsr2.sql
eddt=`date +%H:%M:%S`
echo -e "$bgdt\tStart to dumping dwnews_new_adsr2!"
echo -e "$eddt\tdwnews_new_adsr2 database dump finish!!!"
fi
if [ ! -f /backup/bak_mysqldata/$BACKTIME/dwnews_new_blog.sql ]
then
bgdt=`date +%H:%M:%S`
/usr/local/mysql/bin/mysqldump dwnews_new_blog > /backup/bak_mysqldata/$BACKTIME/dwnews_new_blog.sql
eddt=`date +%H:%M:%S`
echo -e "$bgdt\tStart to dumping dwnews_new_blog!"
echo -e "$eddt\tdwnews_new_blog database dump finish!!!"
fi
if [ ! -f /backup/bak_mysqldata/$BACKTIME/dwnews_new_life.sql ]
then
bgdt=`date +%H:%M:%S`
/usr/local/mysql/bin/mysqldump dwnews_new_life > /backup/bak_mysqldata/$BACKTIME/dwnews_new_life.sql
eddt=`date +%H:%M:%S`
echo -e "$bgdt\tStart to dumping dwnews_new_life!"
echo -e "$eddt\tdwnews_new_life database dump finish!!!"
fi
if [ ! -f /backup/bak_mysqldata/$BACKTIME/dw_shushang.sql ]
then
bgdt=`date +%H:%M:%S`
/usr/local/mysql/bin/mysqldump dw_shushang > /backup/bak_mysqldata/$BACKTIME/dw_shushang.sql
eddt=`date +%H:%M:%S`
echo -e "$bgdt\tStart to dumping dw_shushang!"
echo -e "$eddt\tdw_shushang database dump finish!!!"
fi
if [ ! -f /backup/bak_mysqldata/$BACKTIME/mysql.sql ]
then
bgdt=`date +%H:%M:%S`
/usr/local/mysql/bin/mysqldump mysql > /backup/bak_mysqldata/$BACKTIME/mysql.sql
eddt=`date +%H:%M:%S`
echo -e "$bgdt\tStart to dumping mysql!"
echo -e "$eddt\tmysql database dump finish!!!"
fi
if [ -f /backup/bak_mysqldata/$DELTIME.tgz ]
then
bgdt=`date +%H:%M:%S`
rm -rf /backup/bak_mysqldata/$DELTIME.tgz
eddt=`date +%H:%M:%S`
echo -e "$bgdt\tStart to delete backup on $DELTIME!"
echo -e "$eddt\tbackup databases delete finish in $DELTIME !!!"
fi
cd /backup/bak_mysqldata/
if [ -d /backup/bak_mysqldata/$BACKTIME ]
then
bgdt=`date +%H:%M:%S`
echo -e "$bgdt\tStart to package dump files!"
tar zcvf /backup/bak_mysqldata/$BACKTIME.tgz /backup/bak_mysqldata/$BACKTIME
if [ -f /backup/bak_mysqldata/$BACKTIME.tgz ]
then
rm -rf /backup/bak_mysqldata/$BACKTIME
fi
eddt=`date +%H:%M:%S`
echo -e "$eddt\tPacking dump file is finished!"
fi
[root@rac2 ~]#
BACKTIME=`date +%Y%m%d`
DELTIME=`date +%Y%m%d -d -7day`
echo "===================================$BACKTIME==================================="
if [ ! -d /backup/bak_mysqldata/$BACKTIME ]
then
mkdir /backup/bak_mysqldata/$BACKTIME
fi
cd /backup/bak_mysqldata/$BACKTIME
#if [ ! -f /backup/bak_mysqldata/$BACKTIME/blog_db.sql ]
#then
# bgdt=`date +%H:%M:%S`
# /usr/local/mysql/bin/mysqldump blog_db > /backup/bak_mysqldata/$BACKTIME/blog_db.sql
# eddt=`date +%H:%M:%S`
# echo -e "$bgdt\tStart to dumping blog_db!"
# echo -e "$eddt\tblog_db database dump finish!!!"
#fi
#if [ ! -f /backup/bak_mysqldata/$BACKTIME/dw_data_center.sql ]
#then
# bgdt=`date +%H:%M:%S`
# /usr/local/mysql/bin/mysqldump dw_data_center > /backup/bak_mysqldata/$BACKTIME/dw_data_center.sql
# eddt=`date +%H:%M:%S`
# echo -e "$bgdt\tStart to dumping dw_data_center!"
# echo -e "$eddt\tdw_data_center database dump finish!!!"
#fi
if [ ! -f /backup/bak_mysqldata/$BACKTIME/dwnews_new_adsr1.sql ]
then
bgdt=`date +%H:%M:%S`
/usr/local/mysql/bin/mysqldump dwnews_new_adsr1 > /backup/bak_mysqldata/$BACKTIME/dwnews_new_adsr1.sql
eddt=`date +%H:%M:%S`
echo -e "$bgdt\tStart to dumping dwnews_new_adsr1!"
echo -e "$eddt\tdwnews_new_adsr1 database dump finish!!!"
fi
if [ ! -f /backup/bak_mysqldata/$BACKTIME/dwnews_new_adsr2.sql ]
then
bgdt=`date +%H:%M:%S`
/usr/local/mysql/bin/mysqldump dwnews_new_adsr2 > /backup/bak_mysqldata/$BACKTIME/dwnews_new_adsr2.sql
eddt=`date +%H:%M:%S`
echo -e "$bgdt\tStart to dumping dwnews_new_adsr2!"
echo -e "$eddt\tdwnews_new_adsr2 database dump finish!!!"
fi
if [ ! -f /backup/bak_mysqldata/$BACKTIME/dwnews_new_blog.sql ]
then
bgdt=`date +%H:%M:%S`
/usr/local/mysql/bin/mysqldump dwnews_new_blog > /backup/bak_mysqldata/$BACKTIME/dwnews_new_blog.sql
eddt=`date +%H:%M:%S`
echo -e "$bgdt\tStart to dumping dwnews_new_blog!"
echo -e "$eddt\tdwnews_new_blog database dump finish!!!"
fi
if [ ! -f /backup/bak_mysqldata/$BACKTIME/dwnews_new_life.sql ]
then
bgdt=`date +%H:%M:%S`
/usr/local/mysql/bin/mysqldump dwnews_new_life > /backup/bak_mysqldata/$BACKTIME/dwnews_new_life.sql
eddt=`date +%H:%M:%S`
echo -e "$bgdt\tStart to dumping dwnews_new_life!"
echo -e "$eddt\tdwnews_new_life database dump finish!!!"
fi
if [ ! -f /backup/bak_mysqldata/$BACKTIME/dw_shushang.sql ]
then
bgdt=`date +%H:%M:%S`
/usr/local/mysql/bin/mysqldump dw_shushang > /backup/bak_mysqldata/$BACKTIME/dw_shushang.sql
eddt=`date +%H:%M:%S`
echo -e "$bgdt\tStart to dumping dw_shushang!"
echo -e "$eddt\tdw_shushang database dump finish!!!"
fi
if [ ! -f /backup/bak_mysqldata/$BACKTIME/mysql.sql ]
then
bgdt=`date +%H:%M:%S`
/usr/local/mysql/bin/mysqldump mysql > /backup/bak_mysqldata/$BACKTIME/mysql.sql
eddt=`date +%H:%M:%S`
echo -e "$bgdt\tStart to dumping mysql!"
echo -e "$eddt\tmysql database dump finish!!!"
fi
if [ -f /backup/bak_mysqldata/$DELTIME.tgz ]
then
bgdt=`date +%H:%M:%S`
rm -rf /backup/bak_mysqldata/$DELTIME.tgz
eddt=`date +%H:%M:%S`
echo -e "$bgdt\tStart to delete backup on $DELTIME!"
echo -e "$eddt\tbackup databases delete finish in $DELTIME !!!"
fi
cd /backup/bak_mysqldata/
if [ -d /backup/bak_mysqldata/$BACKTIME ]
then
bgdt=`date +%H:%M:%S`
echo -e "$bgdt\tStart to package dump files!"
tar zcvf /backup/bak_mysqldata/$BACKTIME.tgz /backup/bak_mysqldata/$BACKTIME
if [ -f /backup/bak_mysqldata/$BACKTIME.tgz ]
then
rm -rf /backup/bak_mysqldata/$BACKTIME
fi
eddt=`date +%H:%M:%S`
echo -e "$eddt\tPacking dump file is finished!"
fi
[root@rac2 ~]#
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/90618/viewspace-675704/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 【Mysql】innobackupex備份還原單個庫MySql
- 一個簡單的自動備份alert log指令碼指令碼
- MySQL遠端備份策略舉例MySql
- MySQL自動備份策略的方案MySql
- mysql的一個備份指令碼MySql指令碼
- Mysql資料庫的簡單備份指令碼MySql資料庫指令碼
- oracle備份和恢復策略簡介Oracle
- MySQL中如何選擇合適的備份策略和備份工具MySql
- 刪除前一天的備份的一個簡單批處理
- 【Mysql】備份一個mysql my.cnf配置檔案MySql
- 簡單的mysqldump備份(windows)MySqlWindows
- 備份保留策略
- rman 備份策略
- ORACLE備份策略Oracle
- Oracle備份及備份策略及基於Linux下 Oracle 備份策略(RMAN)OracleLinux
- MySQL備份與恢復簡介MySql
- mysqlbinlog命令詳解 Part 9 MySQL備份策略MySql
- MYSQL定時備份(一)MySql
- 【MySql】 MySql備份工具Xtrabackup之一MySql
- 一次rman備份 策略調整
- ORACLE備份策略(轉)Oracle
- linux 備份策略Linux
- 資料備份策略
- SQL Server 備份策略SQLServer
- ORACLE備份策略(1)Oracle
- ORACLE備份策略(2)Oracle
- ORACLE備份策略(3)Oracle
- ORACLE備份策略(4)Oracle
- Backup policy(備份策略)
- RMAN 備份策略 scripts
- Mac備份策略:更好的Mac備份指南Mac
- MySQL資料備份多種引數介紹及簡單示例MySql
- MYSQL自動備份策略的選擇與實踐MySql
- RMAN備份之備份多個備份集到帶庫(一)
- Mysql備份失敗案例(一)MySql
- MySQL 備份和恢復 一MySql
- gerrit程式碼簡單備份方案分享
- 簡單恢復模式下的備份模式