五、恢复
假定我们需要恢复cp3上一些丢失的数据,首先用amandabackup帐号登录cp2机器,创建/etc/amanda/amanda-client.conf文件,内容如下:
#
# amanda.conf - sample Amanda client configuration file.
#
# This file normally goes in /etc/amanda/amanda-client.conf.
#
conf "FileBackup"# your config name
index_server "cp1.domain.com"# your amindexd server
tape_server "cp1.domain.com"# your amidxtaped server
#tapedev "tape:/dev/YOUR-TAPE-DEVICE-HERE"# your tape device
# if not set, Use configure or ask server.
# if set to empty string "", ask server
# amrecover will use the changer if set to the value
# of 'amrecover_changer' in the server amanda.conf.
# auth- authentication scheme to use between server and client.
# Valid values are "bsd", "bsdudp", "bsdtcp", "krb5", "local",
# "rsh" and "ssh".
# Default: [auth "bsdtcp"]
auth "bsdtcp"
#ssh_keys ""# your ssh keys file if you use ssh auth
然后使用root帐号运行amrecover命令来初始化data恢复过程
[root@cp3 ~]# amrecover
AMRECOVER Version 2.6.1p1. Contacting server on cp1.domain.com ...
220 cp1 AMANDA index server (2.6.1p1) ready.
Setting restore date to today (2009-04-13)
200 Working date set to 2009-04-13.
200 Config set to FileBackup.
200 Dump host set to cp3.domain.com.
Use the setdisk command to choose dump disk to recover
amrecover>
接下的一些命令演示如何将特定的一些数据恢复到指定的目录(这里指定/tmp)
amrecover> listdisk
200- List of disk for host cp3.domain.com
201- /opt/www/sites
200 List of disk for host cp3.domain.com
amrecover> setdisk /opt/www/sites
200 Disk set to /opt/www/sites.
amrecover> ls
2009-04-13-17-49-11 newltf/
2009-04-13-17-49-11 lawburn/
2009-04-13-17-49-11 hnnoritz/
2009-04-13-17-49-11 fireyang/
2009-04-13-17-49-11 admin/
2009-04-13-17-49-11 .htpasswd
2009-04-13-17-49-11 .
amrecover> cd admin
/opt/www/sites/admin
amrecover> ls
2009-04-13-17-49-11 var
2009-04-13-17-49-11 usr
2009-04-13-17-49-11 tmp
2009-04-13-17-49-11 sbin
2009-04-13-17-49-11 lib
2009-04-13-17-49-11 etc
2009-04-13-17-49-11 dev
2009-04-13-17-49-11 bin
2009-04-13-17-49-11 domain.com/
2009-04-13-17-49-11 .
amrecover> cd domain.com
/opt/www/sites/admin/domain.com
amrecover> ls
2009-04-13-17-49-11 var
2009-04-13-17-49-11 usr
2009-04-13-17-49-11 tmp
2009-04-13-17-49-11 subdomains/
2009-04-13-17-49-11 sbin
2009-04-13-17-49-11 mysql/
2009-04-13-17-49-11 lib
2009-04-13-17-49-11 etc
2009-04-13-17-49-11 dev
2009-04-13-17-49-11 bin
2009-04-13-17-49-11 Mailboxs/
2009-04-13-17-49-11 .
amrecover> add subdomains/
Added dir /admin/domain.com/subdomains/ at date 2009-04-13-17-49-11
amrecover> lcd /tmp
amrecover> extract
Extracting files using tape drive changer on host cp1.domain.com.
The following tapes are needed: FileBackup-06
Restoring files into directory /tmp
Continue [?/Y/n]? y
Extracting files using tape drive changer on host cp1.domain.com.
Load tape FileBackup-06 now
Continue [?/Y/n/s/d]? y
./admin/domain.com/subdomains/
./admin/domain.com/subdomains/404/
./admin/domain.com/subdomains/404/bin/
./admin/domain.com/subdomains/404/cgi-bin/
./admin/domain.com/subdomains/404/dev/
./admin/domain.com/subdomains/404/etc/
./admin/domain.com/subdomains/404/html/
./admin/domain.com/subdomains/404/lib/
./admin/domain.com/subdomains/404/libexec/
./admin/domain.com/subdomains/404/logs/
./admin/domain.com/subdomains/404/logs/2009/
./admin/domain.com/subdomains/404/logs/2009/04/
./admin/domain.com/subdomains/404/sbin/
./admin/domain.com/subdomains/404/tmp/
......
我们看看/tmp下面是不是已经有了我们刚才恢复的数据:
[root@cp3 ~]# tree /tmp/admin/domain.com/subdomains/ |more
/tmp/admin/domain.com/subdomains/
|-- 404
| |-- bin
| | |-- bash
| | |-- cat
| | |-- echo
| | |-- false
| | |-- gunzip
| | |-- ls
| | |-- mkdir
| | |-- mv
| | |-- pwd
| | |-- rm
| | |-- scp
| | |-- sftp
| | |-- sh
| | |-- tar
| | |-- unzip
| | `-- zip
| |-- cgi-bin
| |-- dev
| | |-- null
| | |-- random
| | `-- urandom
......
Ok,到此为止,Amanda备份配置基本完成,当然我们很多的配置都是基于缺省定义,比如槽位数,备份周期等,更多详细的定义,可以参考/usr/lib/amanda/example/amanda.conf文件。