1. 介绍
下面的是从百科粘的
Amanda 是最早出现的开源备份
软件。它的名字来自Maryland大学。Amanda的意思是高级Maryland 硬盘归档器.。
Amanda通过
操作系统上一些自带的备份工具,例如tar(Unix/linux)、zip(Windows)来实现备份的计划,自动化和跟踪等功能。采用Amanda可以恢复原来备份过的任何版本的数据。 这种依靠原始备份工具的方式有利有弊。Amanda生成的数据格式在每个
操作系统上都可以使用,这是它最大的优势。不过这些备份工具也有很多的限制(例如 路径长度等),这是Amanda最大的劣势。
Amanda是一款功能强大的产品,它有很多企业级别的功能,例如,可以全自动识别何时进行全备份而无需用户设定。而且Amanda是唯一一款具有SQL Server、Exchange、 SharePoint、Oracle全部代理的
软件,也是唯一一款具有MySQL和Ingress代理的备份软件。
现在Amanda是Zmanda公司的产品,它全面负责Amanda
软件的开发工作。在接管之后的很短的时间内,Zmanda就解决了Amanda许多存在多年的问题。从那时起,这家公司开始负责Amanda的功能性包括数据库代理方面的开发。(这样并不会影响那些原来使用NetWorker产品的用户)。
用户可以选择使用免费版Amanda,帮助主要是来自Amanda论坛的其他用户。当然也可以选择购买Zmanda的商业支持。
2. 配置
节点 | OS | domain name |
server | ubuntu server 12.04 64 | bckserver |
client | ubuntu server 12.04 64 | bckclient |
3. 服务器端安装配置
3.1 安装
# apt-get update
# apt-get install amanda-server amanda-client xinetd gawk gnuplot readline-common openssh-server inetutils-inetd
注意:有些包可能没安装,要检查一下,比如我机器上的xinetd就没有安装,一定要检查
3.2 增加域名解析
编辑/etc/hosts文件,将两个主机的域名与IP对应加入
# vim /etc/hosts
在文件最后加入下面内容
10.10.102.23 bckserver
10.10.102.22 bckclient
3.3 配置inet配置文件
# vim /etc/inetd.conf
#:OTHER: Other services
amandaidx stream tcp nowait backup /usr/sbin/tcpd /usr/lib/amanda/amindexd amindexd -auth=bsdtcp amdump amindexd amidxtaped
amidxtape stream tcp nowait backup /usr/sbin/tcpd /usr/lib/amanda/amidxtaped amidxtaped -auth=bsdtcp amdump amindexd amidxtaped
amanda dgram udp wait backup /usr/sbin/tcpd /usr/lib/amanda/amandad -auth=bsd amdump amindexd amidxtaped
3.4 修改amanda守护进程
修改/etc/xinet.d/amanda文件,使其和下面相同
service amanda
{
disable = no
flags = IPv4
socket_type = stream
protocol = tcp
wait = no
user = backup
group = backup
groups = yes
server = /usr/lib/amanda/amandad
server_args = -auth=bsdtcp amdump amindexd amidxtaped
}
service amidxtape
{
socket_type = stream
protocol = tcp
wait = no
user = backup
group = backup
groups = yes
server = /usr/lib/amanda/amidxtaped
server_args = -auth=bsdtcp amdump amindexd amidxtaped
disable = no
}
修改/etc/xinet.d/amandaidx文件
service amandaidx
{
socket_type = stream
protocol = tcp
wait = no
user = backup
group = backup
groups = yes
server = /usr/lib/amanda/amindexd
server_args = -auth=bsdtcp amdump amindexd amidxtaped
disable = no
}
然后重启xinetd
# /etc/init.d/xinetd restart
3.5 备份配置
# su backup -c "mkdir /etc/amanda/DailySet1"
创建配置文件
/etc/amanda/DailySet1/amanda.conf
org "DailySet1" # your organization name for reports
mailto "backup_admin@mydomain.com" # space separated list of operators at your site
dumpuser "backup" # the user to run dumps under
logdir "/etc/amanda/DailySet1/logs" # log directory
infofile "/etc/amanda/DailySet1/curinfo" # database filename
indexdir "/etc/amanda/DailySet1/index" # index directory
tapelist "/etc/amanda/DailySet1/tapelist" # list of used tapes
tapecycle 9 tapes
tapetype DISK
tpchanger "chg-disk"
changerfile "/etc/amanda/DailySet1/changer" # needed by amlabel
tapedev "file:/space/vtapes/DailySet1/slots"
define tapetype DISK {
comment "Backup to HD"
length 5 gbytes
}
# comment holding disk section if needed
holdingdisk hd1 {
directory "/dumps/"
}
# to be used by any other dumptype
define dumptype global {
comment "Global definitions"
index yes
record yes
auth "bsdtcp"
}
define dumptype daily {
global
comment "daily dumptype"
compress client fast
program "GNUTAR"
strategy standard
priority high
exclude list "/etc/amanda/DailySet1/global-debian-exclude.list"
}
具体参数含义参考 http://wiki.zmanda.com/man/amanda.conf.5.html
然后按照配置文件创建数据仓库
# su backup -c "mkdir /etc/amanda/DailySet1/logs"
# su backup -c "mkdir /etc/amanda/DailySet1/index"
# touch /etc/amanda/DailySet1/tapelist
# su backup -c "mkdir /etc/amanda/DailySet1/curinfo"
3.6 配置存储磁盘
# su backup -c "mkdir /dumps"
# chmod 750 /dumps
3.7 配置虚拟磁盘
# mkdir -p /space/
# mkdir -p /space/vtapes/DailySet1/slots
# chown backup:backup -R /space/
# chmod 750 /space/vtapes
# su backup
$ cd /space/vtapes/DailySet1/slots
然后创建磁盘
$ for ((i=1; $i<=9; i++)); do mkdir slot$i;done
初始化磁盘变更器
$ ln -s slot1 data
标记磁盘
$ for ((i=1; $i<=9;i++)); do amlabel DailySet1 DailySet1-0$i slot $i; done
将磁盘变更器重置到地一个位置
$ amtape DailySet1 reset
通过下面命令检测是否设置成功
$ ls -l data
预想结果:
lrwxrwxrwx 1 backup backup 35 jun 7 02:27 data -> /space/vtapes/DailySet1/slots/slot1
然后修改系统的配置文件/etc/fstab,将这下面内容加到其中( 这一步先不要做)
LABEL=holdingdisk /dumps ext3 defaults 0 0
LABEL=backup /space xfs _netdev 0 0
3.8 备份定义:磁盘列表
我们要备份client端的一个挂载点,所以到client机器执行下面命令:
# mount
结果会有多行,我们选择根目录那一行,然后编辑 /etc/amanda/DailySet1/disklist文件
$ vim /etc/amanda/DailySet1/disklist
加入下面内容
bckclient / daily
3.9 授权:amandahosts
$ vi /etc/amandahosts
加入下面内容
bckserver root amindexd amidxtaped
bckserver backup amdump
bckclient root amindexd amidxtaped
具体参数定义参考 http://wiki.zmanda.com/man/amanda-auth.7.html
# ln -s /etc/amandahosts /var/backups/.amandahosts
# chmod 400 etc/amandahosts
# ls -l /etc/amandahosts
-r-------- 1 backup backup 157 mai 27 02:12 /etc/amandahosts
# ls -l /var/backups/.amandahosts
lrwxrwxrwx 1 root root 16 mai 17 00:41 /var/backups/.amandahosts -> /etc/amandahosts
4. 客户端安装配置
4.1 安装
# apt-get update
# apt-get install amanda-client xinetd openssh-server inetutils-inetd
一定要检查是否全部安装,尤其是xinetd
4.2 配置inetd
# vim /etc/inetd.conf
在最下加入下面内容
#:OTHER: Other services
amanda dgram udp wait backup /usr/sbin/tcpd /usr/lib/amanda/amandad -auth=bsd amdump amindexd amidxtaped
4.3 设置amanda守护进程使用auth bsdtcp
# vim /etc/xinetd.d/amanda
service amanda
{
socket_type = stream
protocol = tcp
wait = no
user = backup
group = backup
groups = yes
server = /usr/lib/amanda/amandad
server_args = -auth=bsdtcp amdump amindexd amidxtaped
disable = no
}
然后重启服务
# service xinetd restart
4.4 客户端配置文件:amanda-client.conf
# vim /etc/amanda/amanda-client.conf
内容如下
conf "DailySet1" # your config name
index_server "bckserver" # your amindexd server
tape_server "bckserver" # your amidxtaped server
auth "bsdtcp"
4.5 授权:amandahosts
编辑amandahosts文件,授权允许server进行备份# vim /etc/amandahosts
内容如下
bckserver backup amdump
具体参数及授权过程参考
http://wiki.zmanda.com/man/amanda-auth.7.html
检查下面命令的结果
# ls -la /var/backups/.amandahosts
预计结果
lrwxrwxrwx 1 root root 23 mai 25 11:19 /var/backups/.amandahosts -> /etc/amandahosts
# ls -l /etc/amandahosts
预计结果
-rw------- 1 backup backup 42 mai 26 23:21 /etc/amandahosts
4.6 排除列表
创建备份时不需进行备份的排除列表,这个文件名称在上面3.5中有定义
$ vim /etc/amanda/DailySet1/global-debian-exclude.list
添加下面内容
./proc
./media
./mnt
./dev
# chmod 644 /etc/amanda/DailySet1/global-debian-exclude.list
5. 测试
5.1 配置测试
用backup用户登录,执行下面命令
$ amcheck DailySet1
预计结果
Amanda Tape Server Host Check
-----------------------------
Holding disk /dumps/: 36401152 kB disk space available, using 36401152 kB
found in slot 8: volume 'DailySet1-08'
slot 8: volume 'DailySet1-08'
Will write to volume 'DailySet1-08' in slot 8.
NOTE: skipping tape-writable test
NOTE: host info dir /etc/amanda/DailySet1/curinfo/bckclient does not exist
NOTE: it will be created on the next run.
NOTE: index dir /etc/amanda/DailySet1/index/bckclient does not exist
NOTE: it will be created on the next run.
Server check took 1.329 seconds
Amanda Backup Client Hosts Check
--------------------------------
Client check: 1 host checked in 2.080 seconds. 0 problems found.
(brought to you by Amanda 3.3.0)
5.2 备份测试
登录到server端用backup帐号登录,执行下面的命令
$ amadmin DailySet1 force bckclient
$ amdump DailySet1
使用下面的命令查看备份文件
$ amadmin DailySet1 find
5.3 备份计划
设置每天1:00am进行备份
# su backup -c "crontab -e"
加入下面内容
0 1 * * 1-7 /usr/sbin/amdump DailySet1
5.4 恢复
登录client端,用root账户登录,进入一个存储目录,比如说/tmp,执行下面命令
# amrecover
AMRECOVER Version 3.3.0. Contacting server on bckserver ...
220 server AMANDA index server (3.3.0) ready.
Setting restore date to today (2013-09-12)
200 Working date set to 2013-09-12.
200 Config set to DailySet1.
501 Host client is not in your disklist.
Trying host client ...
501 Host client is not in your disklist.
Trying host client ...
501 Host client is not in your disklist.
Use the sethost command to choose a host to recover
amrecover> sethost bckclient
200 Dump host set to bckclient.
amrecover> listdisk
201- /
200 List of disk for host bckclient
amrecover> setdisk /
200 Disk set to /.
amrecover> ls
2013-09-12-03-11-33 vmlinuz
2013-09-12-03-11-33 var/
2013-09-12-03-11-33 usr/
2013-09-12-03-11-33 tmp/
2013-09-12-03-11-33 sys/
2013-09-12-03-11-33 srv/
2013-09-12-03-11-33 selinux/
2013-09-12-03-11-33 sbin/
2013-09-12-03-11-33 run/
2013-09-12-03-11-33 root/
2013-09-12-03-11-33 opt/
2013-09-12-03-11-33 lost+found/
2013-09-12-03-11-33 lib64/
2013-09-12-03-11-33 lib/
2013-09-12-03-11-33 initrd.img
2013-09-12-03-11-33 home/
2013-09-12-03-11-33 etc/
2013-09-12-03-11-33 boot/
2013-09-12-03-11-33 bin/
2013-09-12-03-11-33 .
amrecover> add *
Added file /vmlinuz
Added dir /var/ at date 2013-09-12-03-11-33
Added dir /usr/ at date 2013-09-12-03-11-33
Added dir /tmp/ at date 2013-09-12-03-11-33
Added dir /sys/ at date 2013-09-12-03-11-33
Added dir /srv/ at date 2013-09-12-03-11-33
Added dir /selinux/ at date 2013-09-12-03-11-33
Added dir /sbin/ at date 2013-09-12-03-11-33
Added dir /run/ at date 2013-09-12-03-11-33
Added dir /root/ at date 2013-09-12-03-11-33
Added dir /opt/ at date 2013-09-12-03-11-33
Added dir /lost+found/ at date 2013-09-12-03-11-33
Added dir /lib64/ at date 2013-09-12-03-11-33
Added dir /lib/ at date 2013-09-12-03-11-33
Added file /initrd.img
Added dir /home/ at date 2013-09-12-03-11-33
Added dir /etc/ at date 2013-09-12-03-11-33
Added dir /boot/ at date 2013-09-12-03-11-33
Added dir /bin/ at date 2013-09-12-03-11-33
amrecover> extract
Extracting files using tape drive chg-disk on host bckserver.
The following tapes are needed: DailySet1-08
Extracting files using tape drive chg-disk on host bckserver.
Load tape DailySet1-08 now
Continue [?/Y/n/s/d]? y
结果出现下面错误
amrecover - can't talk to tape server: service amidxtaped:
经搜素,发现这是ubuntu LTS 12.04的bug,具体描述在这里
此bug已经修复,但是因为时间问题,还没有验证