AutoMySQLBackup實(shí)現(xiàn)數(shù)據(jù)庫定期備份

AutoMySQLBackup協(xié)助數(shù)據(jù)庫管理者,每日、每周、每月定期備份數(shù)據(jù)庫。 安裝、設(shè)定方法: 1、Sourceforge下載最新版(目前2.5.1-01) 2、加入可執(zhí)行權(quán)限 $ mv automysqlbackup-2.5.1-01.sh /usr/local/bin/automysqlbackup $ chmod +x automysqlbackup 1、設(shè)定cr

AutoMySQLBackup協(xié)助數(shù)據(jù)庫管理者,每日、每周、每月定期備份數(shù)據(jù)庫。
安裝、設(shè)定方法:
1、Sourceforge下載最新版(目前2.5.1-01)
2、加入可執(zhí)行權(quán)限

$ mv automysqlbackup-2.5.1-01.sh /usr/local/bin/automysqlbackup
$ chmod +x automysqlbackup

1、設(shè)定cron
$ crontab -e
設(shè)定每日凌晨1:00執(zhí)行
0 1 * * * /usr/local/bin/automysqlbackup
或者是把a(bǔ)utomysqlbackup復(fù)制到/etc/cron.daily目錄下。
2、在實(shí)際執(zhí)行automysqlbackup,需先設(shè)定幾個值
# 數(shù)據(jù)庫賬號
USERNAME=root
# 數(shù)據(jù)庫密碼
PASSWORD=

# 數(shù)據(jù)庫備份主機(jī)或IP地址,localhost代表本機(jī)
DBHOST=localhost

# 備份數(shù)據(jù)庫,例如 “DB1 DB2 DB3″,all代表所有數(shù)據(jù)庫
DBNAMES=”all”

# 備份文件目錄
BACKUPDIR=”/backup/db”

# Mail setup
# 通知信件內(nèi)容
# – log : send only log file
# – files : send log file and sql files as attachments (see docs)
# – stdout : will simply output the log to the screen if run manually.
# – quiet : Only send logs if an error occurs to the MAILADDR.
MAILCONTENT=”log”

# Set the maximum allowed email size in k. (4000 = approx 5MB email [see docs])
MAXATTSIZE=”4000″

# 通知信件地址
MAILADDR=”maintenance@example.com”

AutoMySQLBackup簡介
AutoMySQLBackup在2.5.1版后,開始支持backup rotation功能,什么意思呢?在2.5版以前,備份文件是會累積越來越多,造成硬盤空間浪費(fèi),而rotation則會清除過舊備份文件。
每日備份,最多備份7天
每周備份,最多備份5周
每月備份,最多備份5個月
超過時間的備份會在執(zhí)行automysqlbackup同時被清除。

? 版權(quán)聲明
THE END
喜歡就支持一下吧
點(diǎn)贊8 分享