快捷搜索:  as  2018  FtCWSyGV  С˵  test  xxx  Ψһ  w3viyKQx

澳门新葡亰app在线下载_龟发之家论坛



原先看到旧版的serve澳门新葡亰app在线下载r administration可以自动备份的,想着workbench应该也可以……没想到竟然不可,而且mysql只是斟酌将这个功能加到community plugin中。忧桑……还好有人写了个AutoMySQLBackup共享在了sourceforge上。碰命运运限怎么样吧。

人家在sourceforge上的先容:

Description

AutoMySQLBackup with a basic configuration will create Daily, Weekly and Monthly backups of one or more of your MySQL databases from one or more of your MySQL servers.

Other Features include:

- Email notification of backups (会有email看护)

- Backup Compression and Encryption (应用压缩和加密)

- Configurable backup rotation (保存的备份文件光阴)

- Incremental database backups (增量型备份)

1.下载AutoMySQLBackup

h澳门新葡亰app在线下载ttp://sourceforge.net/projects/automysqlbackup/

2.解压缩

把下载的automysqlbackup-v3.0_rc6.tar.gz文件拷贝到/usr/tmp下面

在/usr/local下面新建一个automysqlbackup文件夹,并进入这个文件夹

cd /usr/local

mkdir automysqlbackup

cd automysqlbackup

然后terminal解压缩一下。

tar -xzvf /usr/tmp/automysqlbackup-v3.0_rc6.tar.gz

3. 安装

安装一下,敕令为

./install.sh

半途会有两个扣问设置设置设备摆设摆设文件安装目录的地方,之间回车就好

安装完今后会有提示信息,奉告你假如不是当前用户下应用这个敕令要怎么办:

我们先到/etc/automysqlbackup下面看看有什么器械好了

目测有四个文件……

4.改动设置设置设备摆设摆设文件

我们要用到的是automysqlbackup.conf文件:

文件里有一些基础的设置设置设备摆设摆设信息,比如连接mysql server的用户名、密码、IP地址神马的。

# Username to access the MySQL server e.g. dbuser

CONFIG_mysql_dump_username='root'

# Password to access the MySQL server e.g. password CONFIG_mysql_dump_password='1234'

# Host name (or IP address) of MySQL server e.g localhost

CONFIG_mysql_dump_host='localhost'

续,有个紧张的设置设置设备摆设摆设,便是backup寄放的地方咯!

# Backup directory location e.g /backups

CONFIG_backup_dir='/var/backup/db'

往下看,还有你要设置设置设备摆设摆设的database的名称,当然可以正确到表名,也可以只指定到database的名称。或者干脆直接留空,不过留空的话会默认备份所有的数据库……这样磁盘可能会爆炸吧……

# Databases to backup

# List of databases for Daily/Weekly Backup e.g. ( 'DB1' 'DB2' 'DB3' ... )

# set to (), i.e. empty, if you want to 澳门新葡亰app在线下载backup all databases CONFIG_db_names=()

# You can use #declare -a MDBNAMES=( "${DBNAMES[@]}" 'added entry1' 'added entry2' ... )

# INSTEAD to copy the contents of $DBNAME澳门新葡亰app在线下载S and add further entries (optional).

# List of databases for Monthly Backups. # set to (), i.e. empty, if you want to backup all databases

CONFIG_db_month_names=()

# List of DBNAMES to EXLUCDE if DBNAMES is empty, i.e. (). CONFIG_db_exclude=( 'information_schema' 'wiqun' )

别的,还有设置设置设备摆设摆设weekly、monthly、daily之类的光阴距离的设置

# Rotation Settings

# Which day do you want monthly backups? (01 to 31)

# If the chosen day is greater than the last day of the month, it will be done # on the last day of the month.

# Set to 0 to disable monthly backups. CONFIG_do_monthly="22"

# Which day do you want weekly backups? (1 to 7 where 1 is Monday)

# Set to 澳门新葡亰app在线下载0 to disable weekly backups. CONFIG_do_weekly="7"

# Set rotation of daily backups. VALUE*24hours

# If you want to keep only today's backups, you could choose 1, i.e. everything older than 24hours will be removed. CONFIG_rotation_daily=7

# Set rotation for weekly backups. VALUE*24hours

CONFIG_rotation_weekly=35

# Set rotation for monthly backups. VALUE*24hours CONFIG_rotation_monthly=150

前两个都对照好理解,便是每个月或者每一周的什么时刻进行自动备份,假如不想应用每周备份或者每月备份的话,响应的地方设置0即可。那么后面的rotation又是什么意思呢?着实便这天志保存的刻日啦。

比如说CONFIG_rotation_weekly=35的意思便是说按周存储的备份最多保留35天。

再继承,可以设置设置设备摆设摆设发送邮件的一些设置设置设备摆设摆设,比如邮件地址啦、还有附件的内容啦。

# What would you like to be mailed to you?

# - 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.

CONFIG_mailcontent='files'

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

# Allow packing of files with tar and splitting it in pieces of CONFIG_mail_maxattsize.

CONFIG_mail_splitandtar='yes'

# Use uuencode instead of mutt. WARNING: Not all email clients work well with uuencoded attachments. #CONFIG_mail_use_uuencoded_attachments='no'

# Email Address to send mail to? (user@domain.com)

CONFIG_mail_address='elarwei@gmail.com'

5. 运行Automysqlbackup

要运行automysqlbackup之前呢,不要忘了先新建我们寄放备份数据库文件的地方,即在设置设置设备摆设摆设文件中设定的“/var/backup/db”,现在我们来新建这个目录。

mkdir /var/backup

mkdir /var/backup/db

好了,现在我们可以run一下automysqlbackup了。敕令是:

automysqlbackup /etc/automyslqbackup/automysqlbackup.conf

噔噔,怎么报错了呢?

Parsed config file "/etc/automysqlbackup/automysqlbackup.conf"

# Checking for permissions to write to folders:

base folder /var/backup ... exists ... ok. backup folder /var/backup/db ... exists ... writable? yes. Proceeding.

/usr/local/bin/automysqlbackup: line 139: mutt: command not found

好吧,有事问Google。

sourceForge上公然也有人碰到过这个问题……,解答是

Please set CONFIG_mailcontent='stdout' in your config file and try again from your console.

The output should directly be displayed.It seems some error occured before the check for config variables could determine

whether there is a need for checking if mutt (mail program) is installed and can be used.Therefore the error handler tried to mail the errors using mutt (your configuration choice), which isn't there.

大年夜 意便是说在设置设置设备摆设摆设文件里面应用了发送email来申报error这个东东,然则你的机子上却没安装mutt这个法度榜样,以是在检测设置设置设备摆设摆设的时刻就发生了差错。解 决的措施是把报错改成“stdout”,不过假如改成“stdout”不就掉去了我们发送申报到email 的本意了吗……so,我们安装一下mutt这个法度榜样好了。

(PS:假如不应用发送邮件则不必要这个步骤)

.1 安装mutt

敕令是

yum install mutt

安装完了今后我们再从新run一下automysqlbackup。

此次没有报错了。我们到/var/backup/db下面看一下有没有什么变更

cd /var/backup/db

ls

呈现了几个文件夹哦

6. 设定Cron Job

Cron 是一个可以让系统准时运行后台脚本的对象。

6.1 编写可履行脚本

我们在/usr/local/bin目录下编写一个要准时履行的脚本

#!/bin/sh

/usr/local/bin/automysqlbackup /etc/automysqlbackup/automysqlbackup.conf

您可能还会对下面的文章感兴趣: