目前备份软件很多,但是开源云备份软件,目前接触的就是Amanda,本文主要目的是对Amanda备份软件的安装配置验证过程,只是涉及磁盘到磁盘的备份,采用虚拟两个linux操作系统,实现指定数据的备份过程,关于云端的备份,在后续研究中总结。文中有不对的地方还请各位包含。


Amanda网站提供了一篇"The 15-Minute Backup Solution"文章,本文根据该文件整理改进得到。


安装环境:

操作系统:Red Hat Enterprise Linux 6.4  64位 (安装在两个虚拟机主机名分别为:server  client)

下载的软件:amanda-backup_server-3.3.7-1.rhel6.x86_64.rpm(安装服务端:server)   amanda-backup_client-3.3.7-1.rhel6.x86_64.rpm(安装客户端:client) 

下载地址:http://www.zmanda.com/download-amanda.php 

还需要安装部分软件,NFS、sharutils、gpg、xinetd


客户端 client:安装 Amanda backup client 

1. rpm软件包amanda-backup_client-3.3.7-1.rhel6.x86_64.rpm

2. rpm -ivh amanda-backup_client-3.3.7-1.rhel6.x86_64.rpm

3.确保/etc/xinetd.d/amandaserver 文件内容与下述一致

#vim  /etc/xinetd.d/amandaserver


# default: on
#
# description: Amanda services for Amanda server and client.
#
service amanda
{
        disable = no
        flags           = IPv4
        socket_type     = stream
        protocol        = tcp
        wait            = no
        user            = amandabackup
        group           = disk
        groups          = yes
        server          = /usr/libexec/amanda/amandad
        server_args     = -auth=bsdtcp amdump amindexd amidxtaped
}

4. 重启xinetd服务

# service xinetd restart

5.修改/var/lib/amanda/.amandahosts文件

#  echo quartz.zmanda.com amandabackup amdump >> /var/lib/amanda/.amandahosts

 chmod 700 /var/lib/amanda/.amandahosts

6.#  su amandabackup

$ chown amandabackup:disk ~amandabackup/.am_passphrase

$ chmod 700 ~amandabackup/.am_passphrase

7./usr/sbin/amcryptsimple该文件权限修改

# chown amandabackup:disk /usr/sbin/amcryptsimple

# chmod 750 /usr/sbin/amcryptsimple


服务端:安装Amanda backup server

1.rpm软件包: amanda-backup_server-3.3.7-1.rhel6.x86_64.rpm
2. rpm -ivh amanda-backup_server-3.3.3-1.rhel6.x86_64.rpm
3.确保/etc/xinetd.d/amandaserver 文件内容与下述一致

# vim  /etc/xinetd.d/amandaserver  

# default: on
#
# description: Amanda services for Amanda server and client.
#
service amanda
{
        disable = no
        flags           = IPv4
        socket_type     = stream
        protocol        = tcp
        wait            = no
        user            = amandabackup
        group           = disk
        groups          = yes
        server          = /usr/libexec/amanda/amandad
        server_args     = -auth=bsdtcp amdump amindexd amidxtaped
}**一般不需要改动。

4. 重启xinetd服务
service xinetd restart



设置备份参数

1.建立设置文件夹
# su - amandabackup       //使用amandabackup用户
$ mkdir /etc/amanda/DailySet1      // 设置需要备份的组织名称
$ cp /var/lib/amanda/example/amanda.conf /etc/amanda/DailySet1       //复制配置文件到当前新建的目录

2.修改配置文件

$ vim /etc/amanda/DailySet1/amanda.conf //修改一下内容


org      "DailySet1"    # your organization name for reports项目名称
mailto   "admin@mailaddress"      # space separated list of operators at your site备份机构发送的邮箱地址
dumpuser "amandabackup" # the user to run dumps under备份使用的用户名
tpchanger "chg-disk"

runtapes 1                      # number of tapes to be used in a single run of amdump
tapedev "file://space/vtapes/DailySet1/slots"   # tape changer or device to use  虚拟磁带目录

tapetype HARDDISK               # what kind of tape it is (see tapetypes below)
labelstr "^DailySet1-[0-9][0-9]*$"      # label constraint regex: all tapes must match

amrecover_changer "changer" 

holdingdisk hd1 {
    comment "main holding disk"
    directory "/dumps/amanda"   # where the holding disk is 缓存文件夹后面需要新建
    use -100 Mb                
    chunksize 1Gb       
}

define tapetype HARDDISK {
length 100000 mbytes
}

define dumptype global {
    comment "Global definitions"
    auth "bsdtcp"
}

//在amanda.conf文件中其它项目保持不变。

3.创建备份缓存盘
# mkdir -p /dumps/amanda
# chown amandabackup:disk /dumps/amanda
# chmod 750 /dumps/amanda

4. 创建虚拟磁带
# mkdir -p /space/vtapes
# chown amandabackup:disk /space/vtapes
# chmod 750 /space/vtapes

# su - amandabackup                                
$ touch /etc/amanda/DailySet1/tapelist
$ mkdir -p /space/vtapes/DailySet1/slots
$ cd /space/vtapes/DailySet1/slots
$ for ((i=1; $i<=25; i++)); do mkdir  slot$i;done
$ ln -s slot1 data

5.对磁带进行label
$ for ((i=1; $i<=9;i++)); do amlabel DailySet1 DailySet1-0$i slot $i; done
$ for ((i=10; $i<=25;i++)); do amlabel DailySet1 DailySet1-$i slot $i; done
$ amtape DailySet1 reset                    **复位磁带changer至第一个磁带

$ amdevcheck DailySet1  //amdevcheck查检配置文件是否正确,确保返回success

SUCCESS


6.创建备份列表文件

$ vim /etc/amanda/DailySet1/disklist   //该文件存储了需要备份的主机、目录和备份方式

client /home/test comp-user-tar


7.创建互相访问需要的用户名

$ vim /var/lib/amanda/.amandahosts 

client root amindexd amidxtaped  //确保访问client使用root用户名
server amandabackup admump   //确保访问server使用amandabackup用户名


8.确认网络地址

# vim /etc/hosts      //将一下内容插入该文件

192.168.60.55  server   //服务端地址

192.168.60.57  client    //客户端地址


9.检查设置
$ amcheck DailySet1   
...
Client check: 1 host checked in 1.218 seconds.  0 problems found.   //确保没有问题
(brought to you by Amanda 3.3.7)


10. 手工运行一次备份

$ amdump DailySet1

11. 检查执行结果

$ amadmin DailySet1 find

........    //  显示备份清单

12.指定自动运行

$  crontab -e 

0 1 * * 1-5 /usr/sbin/amdump DailySet1  // 该内容插入文件,实现周一至周五每晚1点备份

备份成功!!!



客户端(client)恢复:


1.首先配置恢复文件

# vim /etc/amanda/amanda-client.conf

# amanda.conf - sample Amanda client configuration file.
#
# This file normally goes in /etc/amanda/amanda-client.conf.
#
conf "DailySet1" # your config name

index_server "server" # your amindexd server

tape_server "server" # your amidxtaped server

#tapedev "/dev/null" # your tape device     //这个本实验需要注销掉
# auth - authentication scheme to use between server and client.
# Valid values are "bsd", "bsdudp", "bsdtcp" and "ssh".
# Default: [auth "bsdtcp"]

auth "bsdtcp"

# your ssh keys file if you use ssh auth

ssh_keys "/var/lib/amanda/.ssh/id_rsa_amrecover"



2.进入你要把数据恢复的目的目录处,以root身份运行amrecover

#amrecover

AMRECOVER Version 3.3.7.1p2. Contacting server on quartz.zmanda.com ...
220 quartz AMANDA index server (3.3.7.1p2) ready.
Setting restore date to today (2015-06-08)
200 Working date set to 2015-06-08.
200 Config set to DailySet1.
501 Host copper is not in your disklist.
Trying host server ...
200 Dump host set to client.
Use the setdisk command to choose dump disk to recover

amrecover> listdisk

200- List of disk for host client
201- /honme/test
200 List of disk for host client

amrecover> setdisk /honme/test

200 Disk set to /honme/test

amrecover> ls

  .....  //显示备份清单

amrecover> add  **

 .    ....  //增加需要恢复的目录

amrecover> extract  //开始执行

.................//选择Y  就ok

amrecover> quit
200 Good bye.

恢复完成!!

listdisk   ** 查看已经备份的磁盘或目录
setdisk  ** 打开指定的备份磁盘或目录
ls          ** 显示目录中备份过的内容
add      **  指定要恢复的文件或子目录
lcd        ** 指定恢复的目标目录
extract  **按上述设定恢复数据
quit      **  退出amrecover程序