Zrm是zmanda公司开发的一个mysql备份还原工具。
下载地址为:http://www.zmanda.com/download-zrm.php
根据版本选择对应的工具。
安装zrm之前需要安装关于perl和DBI等一系列的包,因为zrm使用perl写的一个脚本工具。
下面是测试的环境:
OS:RHEL5.4 i386
MYSQL:5.5.16
Zrm:ZRM for MySQL Community Edition - version 2.2.0
安装zrm,直接rpm -ivh rpm包即可。
配置zrm
cd /etc/mysql-zrm/ cp mysql-zrm test/ cp mysql-zrm.conf test/ cd test/ vi mysql-zrm.conf |
#comment=This is a comment backup-level=0 backup-mode=raw #lvm-snapshot=10M #snapshot-plugin="/usr/share/mysql-zrm/plugins/lvm-snapshot.pl"
# Specifies the type of backup # Values can be "regular" or "quick". # Quick backup type uses the snapshot itself as the backup # without copying the data from the snapshot volume #backup-type=quick
destination=/var/lib/mysql-zrm retention-policy=10W #replication=1 #compress=1 compress-plugin参数,默认为不进行数据压缩。 #compress-plugin=/usr/bin/gzip #encrypt=1 encrypt-plugin必须呗设置。 #encrypt-plugin="/usr/share/mysql-zrm/plugins/encrypt.pl"decrypt-option也需要被设置。 #decrypt-option="-d" #all-databases=1 databases=wikidb forums all-databases #tables=text user page #database="wikidb" tables要备份的几个表属于哪个库 # exclude-pattern= #user="wikiuser" #password="userwiki" #host="localhost.company.com" #port=3306 #socket=/var/lib/mysql/mysql.sock #ssl-options="--ssl --ssl-ca=file1 --ssl-cert=file2 --ssl-key=file3" #routines=1 #single-transaction=0 #default-character-set=latin1 #mysql-binpath="/opt/lampp/bin" #mysql-binlog-path="/var/log/mysql" #tmpdir=/tmp
#verbose=1 #mailto="mysqldba@company.com" #mail-policy=always |
测试
backup-level=0 backup-mode=raw destination=/tmp/mysql-zrm retention-policy=10D compress=1 #all-databases=1 databases=test rvdb_bailh tables=t1 tl test `Test` database=test user="root" password="" socket=/tmp/mysql.sock verbose=1 port=3306 single-transaction=1 routines=1 |
mysql> show tables; +----------------+ | Tables_in_test | +----------------+ | Test | | t1 | | test | | tl | +----------------+ 4 rows in set (0.00 sec)
[root@basic test]# mysql-zrm-backup --backup-set test [root@basic test]# cd /tmp/mysql-zrm/test [root@basic test]# ll total 4 drwx------ 2 root root 4096 Dec 8 14:10 20111208141003 mysql> drop table t1; Query OK, 0 rows affected (0.01 sec) mysql> drop table test; Query OK, 0 rows affected (0.01 sec) mysql> drop table tl; Query OK, 0 rows affected (0.00 sec) mysql> show tables; +----------------+ | Tables_in_test | +----------------+ | Test | +----------------+ 1 row in set (0.00 sec) [root@basic test]# mysql-zrm-restore --source-directory=/tmp/mysql-zrm/test/20111208141003 mysql> show tables; +----------------+ | Tables_in_test | +----------------+ | Test | | t1 | | test | | tl | +----------------+ 4 rows in set (0.00 sec) 恢复成功。 |
查看备份的报告
[root@basic test]# mysql-zrm-reporter --where backup-set=test --show backup-status-info REPORT TYPE : backup-status-info
backup_set backup_date backup_level backup_status backup_type comment ----------------------------------------------------------------------------------------------------------------------------- test Thu 08 Dec 2011 02:10:03 0 Backup succeeded regular ---- PM CST |
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/24212278/viewspace-712949/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/24212278/viewspace-712949/