Heim  >  Artikel  >  Datenbank  >  AutoMySQLBackup实现数据库定期备份

AutoMySQLBackup实现数据库定期备份

WBOY
WBOYOriginal
2016-06-07 17:58:49851Durchsuche

AutoMySQLBackup协助数据库管理者,每日、每周、每月定期备份数据库。 安装、设定方法: 1、Sourceforge下载最新版(目前2.5.1-01) 2、加入可执行权限 $ mv automysqlbackup-2.5.1-01.sh /usr/local/bin/automysqlbackup $ chmod +x automysqlbackup 1、设定cr

AutoMySQLBackup协助数据库管理者,每日、每周、每月定期备份数据库。
安装、设定方法:
1、Sourceforge下载最新版(目前2.5.1-01)
2、加入可执行权限

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


1、设定cron
$ crontab -e
设定每日凌晨1:00执行
0 1 * * * /usr/local/bin/automysqlbackup
或者是把automysqlbackup复制到/etc/cron.daily目录下。
2、在实际执行automysqlbackup,需先设定几个值
# 数据库账号
USERNAME=root
# 数据库密码
PASSWORD=

# 数据库备份主机或IP地址,localhost代表本机
DBHOST=localhost

# 备份数据库,例如 "DB1 DB2 DB3",all代表所有数据库
DBNAMES="all"

# 备份文件目录
BACKUPDIR="/backup/db"

# Mail setup
# 通知信件内容
# - 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版以前,备份文件是会累积越来越多,造成硬盘空间浪费,而rotation则会清除过旧备份文件。
每日备份,最多备份7天
每周备份,最多备份5周
每月备份,最多备份5个月
超过时间的备份会在执行automysqlbackup同时被清除。
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn