Linux shell實(shí)現(xiàn)每天定時(shí)備份mysql數(shù)據(jù)庫
更新時(shí)間:2015年03月29日 14:49:50 投稿:hebedich
這篇文章主要介紹了Linux shell實(shí)現(xiàn)每天定時(shí)備份mysql數(shù)據(jù)庫的代碼,分享給大家,希望大家能夠喜歡。
每天定時(shí)備份mysql數(shù)據(jù)庫任務(wù),刪除指定天數(shù)前的數(shù)據(jù),保留指定天的數(shù)據(jù);
需求:
1,每天4點(diǎn)備份mysql數(shù)據(jù);
2,為節(jié)省空間,刪除超過3個月的所有備份數(shù)據(jù);
3,刪除超過7天的備份數(shù)據(jù),保留3個月里的 10號 20號 30號的備份數(shù)據(jù);
#創(chuàng)建shell文件 vim backup_mysql.sh mysqldump -uroot -p123456 --all-databases > /data/dbdata/mysqlbak/`date +%Y%m%d`.sql find /data/dbdata/mysqlbak/ -mtime +7 -name '*[1-9].sql' -exec rm -rf {} \; find /data/dbdata/mysqlbak/ -mtime +92 -name '*.sql' -exec rm -rf {} \; #創(chuàng)建定時(shí)任務(wù) crontab –e 0 4 * * * /data/dbdata/backup_mysql.sh
以上所述就是本文的全部內(nèi)容了,希望對大家能夠熟練掌握shell腳本有所幫助。
您可能感興趣的文章:
- linux實(shí)現(xiàn)mysql數(shù)據(jù)庫每天自動備份定時(shí)備份
- linux實(shí)現(xiàn)定時(shí)備份mysql數(shù)據(jù)庫的簡單方法
- MySQL數(shù)據(jù)庫定時(shí)備份的實(shí)現(xiàn)方法
- shell腳本實(shí)現(xiàn)mysql定時(shí)備份、刪除、恢復(fù)功能
- linux定時(shí)備份MySQL數(shù)據(jù)庫并刪除以前的備份文件(推薦)
- mysql定時(shí)自動備份數(shù)據(jù)庫的方法步驟
- MySQL 數(shù)據(jù)庫定時(shí)備份的幾種方式(全面)
- Linux系統(tǒng)每日定時(shí)備份mysql數(shù)據(jù)的方法步驟
相關(guān)文章
shell學(xué)習(xí)教程獲取命令行參數(shù)示例
這篇文章主要介紹了shell學(xué)習(xí)中的基礎(chǔ)知識的獲取命令行參數(shù)示例,需要的朋友可以參考下2014-03-03