参考:

http://blog.secaserver.com/2013/02/centos-restore-recover-amanda-backup/

一、前言

Amanda简介

Amanda (Advanced Maryland Automatic Network Disk Archiver,马里兰高级自动网络磁盘存档工具) 是由马里兰大学的James da Silva在1991年所开发的。它是一个复杂的网络备份系统,能够把LAN中的所有计算机备份到一台服务器的磁带驱动器、磁盘或光盘上。

Amanda本身并不是备份程序,它其实只是管理其他备份软件的封装软件。它使用系统上的dump和restore命令作为底层的备份软件,同时也能够使用tar命令,针对于windows计算机,Amanda还能够使用smbtar命令来实现备份。

Amanda支持类型广泛的磁带驱动器,并且能够使用磁带驱动器中的硬件压缩功能,或者也可以在数据通过网络之前使用客户机的compress以及gzip命令来压缩备份。其次,Amanda能够使用临时保存磁盘作为备份存档的中间存储媒介,以优化磁带的写入性能并保证在磁带出错时也能备份数据。

Amanda是当前最流行的免费备份解决方案,目前Amanda最新的稳定版本是2.5.2p2。通过 http://www.amanda.org站点可以免费获得。

Amanda工作方式

Amanda 综合使用完全备份和增量备份来保存所负责的全部数据,使用最小的、有可能是每日的备份集。一台 Amanda 服务器可以备份任意数量执行 Amanda 的客户机或是将连上 Amanda 服务器的计算机上的数据备份到一台磁带机上。一个常见的问题是,数据写入磁带机的时间将超过取行数据的时间,而 Amanda 解决了这个问题。它使用一个 “holding disk” 来同时备份几个文件系统。 Amanda 建立 “archive sets” 的一组磁带,用来备份在 Amanda 的配置文件中所列出的完整的文件系统。

Amanda 的整体策略是:在每次周期中完成一次数据的完全备份,并且确保在两次完全转储之间备份所有更改的数据。传统的做法是先执行完全备份,然后在此期间执行增量备份。而Amanda 的工作方式不同的是,每次运行Amanda 都对部分数据进行完全备份,确切地说,就是在一个完整的备份周期内备份全部数据所需备份的其中一部分。例如,如果周期为 7 天,且一个周期内进行7次备份,则每天必须备份 1/7 的数据,以便在 7 天之内完成一次完全备份。除了这个“部分”完全备份外,Amanda 还对自最近一次完全备份后更改的数据进行增量备份。Amanda这种特有的备份策略,可以减少每次备份的数据量。

二、Amanda的安装部署

服务器端:

安装

1.安装amanda,修改配置文件

yum install -y amanda*

2.创建配置文件

mkdir /etc/amanda/ServerNetBackup
vim /etc/amanda/ServerNetBackup/amanda.conf

配置文件如下:

org "ServerNetBackup"                 # Organization name for reports
mailto "address@youremail.com"        # Email address to receive reports
netusage 10000 Kbps                   # Bandwidth limit, 10M
 
dumpcycle 1 week                      # Backup cycle is 7 days
runspercycle 7                        # Run 7 times every 7 days
tapecycle 8 tapes                    # Dump to 8 different tapes during the cycle
tpchanger "chg-disk"                  # The tape-changer glue script
 
changerfile "/etc/amanda/ServerNetBackup/changer"     # The tape-changer file
 
tapedev "file://central_backup/ServerNetBackup/slots" # The no-rewind tape device to be used
tapetype HARDDISK                                     # Define the type of tape
 
infofile "/etc/amanda/ServerNetBackup/curinfo"        # Database directory
logdir "/etc/amanda/ServerNetBackup/logs"             # Log directory
indexdir "/etc/amanda/ServerNetBackup/index"          # Index directory
 
define tapetype HARDDISK {                            # Define our tape behaviour
length 1000 mbytes                                  # Every tape is 1GB in size
}
 
amrecover_changer "changer"                           # Changer for amrecover
 
define dumptype global {                              # The global dump definition
maxdumps 2                                            # The maximum number of backups run in parallel
estimate calcsize                                     # Estimate the backup size before dump
holdingdisk yes                                       # Dump to temp disk (holdingdisk) before backup to tape
index yes                                             # Generate index. For restoration usage
}
 
define dumptype root-tar {                            # How to dump root's directory
global                                                # Include global (as above)
program "GNUTAR"                                      # Program name for compress
comment "root partitions dumped with tar"
compress none                                         # No compress
index                                                 # Index this dump
priority low                                          # Priority level
}
 
define dumptype user-tar {                            # How to dump user's directory
root-tar                                              # Include root-tar (as above)
comment "user partitions dumped with tar"
priority medium                                       # Priority level
}
 
define dumptype comp-user-tar {                       # How to dump & compress user's directory
user-tar                                              # Include user-tar (as above)
compress client fast                                  # Compress in client side with less CPU (fast)
}

创建备份的位置

1.创建虚拟磁带目录

mkdir -p /central_backup/ServerNetBackup/slots

2.修改目录的权限

chown amandabackup.disk /central_backup -Rf
chown amandabackup.disk /etc/amanda/ServerNetBackup -Rf

3.切换amandabackup用户,创建虚拟磁带,存放备份文件

for n in `seq 1 8`; do mkdir /central_backup/ServerNetBackup/slots/slot${n}; done

4.为每个磁带做一个标签

for n in `seq 1 8` ; do amlabel ServerNetBackup ServerNetBackup-${n} slot ${n}; done

5.创建配置文件里定义好的目录

mkdir /etc/amanda/ServerNetBackup/{curinfo,logs,index}

配置需要备份的机器(客户端)和备份目录

1.切换amandabackup用户,创建disklist文件,这个文件存放的是客户端和对应的备份目录

su - amandabackup
vim /etc/amanda/ServerNetBackup/disklist

增加以下几行

client1 /home/data   comp-user-tar
client2.org  /data2  root-tar

2.修改/etc/hosts,确保服务端与客户端之间是互通的

192.168.15.34 client1
192.168.15.224 client2.org

3.切换root用户,修改xinetd.d的amanda服务

vim /etc/xinetd.d/amanda

配置文件如下:

# default: off
# description: The client for the Amanda backup system.\
# This must be on for systems being backed up\
# by Amanda.
service amanda
{
        socket_type = dgram
        protocol = udp
        wait = yes
        user = amandabackup
        group = disk
        server = /usr/sbin/amandad
# Configure server_args for the authentication type you will be using,
# and the services you wish to allow the amanda server and/or recovery
# clients to use.
#
# Change the -auth= entry to reflect the authentication type you use.
# Add amindexd to allow recovery clients to access the index database.
# Add amidxtaped to allow recovery clients to access the tape device.
        server_args = -auth=bsd amdump 
        disable = no
}

4.开机启动xinetd

chkconfig xinetd on
service xinetd restart

5.查看amanda服务是否已经开启

netstat -a | grep amanda

客户端

1.安装amanda

yum install -y amanda amanda-client

2.切换到amandabackup用户,修改 /var/lib/amanda/.amandahosts,添加服务器端的域名

su - amandabackup
vim /var/lib/amanda/.amandahosts

3.修改xinetd.d监控的amanda服务,如上

4.开机启动xinetd.d,如上

5.在/etc/hosts文件中添加服务器端的域名解析

192.168.15.214 office.servering.com
192.168.15.224 client2.org

6.修改备份目录的权限

chmod 755 /home/data

三、测试amanda备份

1.在服务器端,切换amandabackup用户,测试配置是否正确

su - amandabackup
amcheck ServerNetBackup

2.如无错误,开始备份客户端的目录

amdump ServerNetBackup

3.可以添加按时备份的计划任务

0 5 * * 6 /usr/sbin/amdump ServerNetBackup

四、Amanda还原备份测试

amanda服务器端

1.修改/var/lib/amanda/.amandahosts文件,授权客户端可以进行的操作

client2.org root amindexd amidxtaped
client1 root amindexd amidxtaped
office.servering.com root amindexd amidxtaped
office.servering.com amandabackup amdump

2.修改/etc/xinetd.d/amanda

# default: off
# description: The client for the Amanda backup system.\
# This must be on for systems being backed up\
# by Amanda.
service amanda
{
        socket_type = dgram
        protocol = udp
        wait = yes
        user = amandabackup
        group = disk
        server = /usr/sbin/amandad
# Configure server_args for the authentication type you will be using,
# and the services you wish to allow the amanda server and/or recovery
# clients to use.
#
# Change the -auth= entry to reflect the authentication type you use.
# Add amindexd to allow recovery clients to access the index database.
# Add amidxtaped to allow recovery clients to access the tape device.
        server_args = -auth=bsd amdump amindexd amidxtaped
        disable = no
}

amanda客户端

1.修改/etc/amanda/amanda-client.conf或者自定义一个文件夹/etc/amanda/ServerNetBackup/amanda-client.conf

#
# amanda.conf - sample Amanda client configuration file.
#
# This file normally goes in /etc/amanda/amanda-client.conf.
#
conf "ServerNetBackup" # your config name
index_server "office.servering.com" # your amindexd server
tape_server "office.servering.com" # your amidxtaped server
tapedev "chg-disk"  #需要自己添加
#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 "bsd"  
#auth方式务必和server端的一致,不然会连接不上
ssh_keys "" # your ssh keys file if you use ssh auth
#resolves "resource temporarily unavailable" bug
unreserved-tcp-port 1025,65535

在客户端的还原过程

在客户端1上还原数据

1.进入将要restore备份的目录

cd /data/backup/tmp

2.连接amanda服务器

amrecover ServerNetBackup -s office.servering.com

3.列出已经备份的目录

amrecover> listdisk
200- List of disk for host client1
201- /home/data
200 List of disk for host client1
amrecover>

4.选择将要还原的备份

amrecover> setdisk /home/data
200 Disk set to /home/data.
amrecover>

5.查看备份的时间

amrecover> history
200- Dump history for config "ServerNetBackup" host "client1" disk /home/data
201- 2014-12-25-20-07-22 0 ServerNetBackup-1:1
201- 2014-12-25-17-21-32 0 ServerNetBackup-8:1
200 Dump history for config "ServerNetBackup" host "client1" disk /home/data
amrecover>

6.选择一个还原备份的时间点

amrecover> setdate 2014-12-25-20-07-22
200 Working date set to 2014-12-25-20-07-22.
amrecover> ls
2014-12-25-20-07-22 Python-2.7.3-1.x86_64_mccq6.2.rpm
2014-12-25-20-07-22 .
amrecover>

7.选择要还原的文件

amrecover> add * #或者add filename
Added file /Python-2.7.3-1.x86_64_mccq6.2.rpm
amrecover>

8.还原备份

amrecover> extract
Extracting files using tape drive chg-disk on host office.servering.com.
The following tapes are needed: ServerNetBackup-1
Restoring files into directory /data/backup/tmp
Continue [?/Y/n]? y
Extracting files using tape drive chg-disk on host office.servering.com.
Load tape ServerNetBackup-1 now
Continue [?/Y/n/s/d]? y
./Python-2.7.3-1.x86_64_mccq6.2.rpm
amrecover>

9.退出amrecover

amrecover> quit

在客户端1上还原客户端2的数据

1.进入将要restore备份的目录

cd /data/backup/tmp

2.连接amanda服务器

amrecover ServerNetBackup -s office.servering.com

3.列出所有客户端

amrecover> listhost
200- List hosts for config ServerNetBackup
201- client1
201- client2.org
200 List hosts for config ServerNetBackup

4.选择要还原的客户端

amrecover> sethost client1
200 Dump host set to client1.

5.开始还原,还原过程如上

在服务器端还原数据

1.以root用户创建还原数据存放的目录

mkdir -pv /data/amandatest2
chown amandabackup.disk amandatest2

2.以amandabackup用户还原数据

su - amandabackup
cd /data/amandatest2
#查看当前服务器上所有客户端的备份目录
amadmin ServerNetBackup find
# 用法
amadmin ServerNetBackup find [<hostname> [<disks>]* ]*
amadmin ServerNetBackup find

返回:

date host disk lv tape or file file part status
2014-12-25 17:21:32 client1 /home/data 0 ServerNetBackup-8 1 1/1 OK
2014-12-25 20:07:22 client1 /home/data 0 ServerNetBackup-1 1 1/1 OK
2015-01-05 11:07:51 client1 /home/data 0 ServerNetBackup-3 1 1/1 OK
2014-12-25 17:21:32 client2.org /data2 0 ServerNetBackup-8 2 1/1 OK
2014-12-25 20:07:22 client2.org /data2 1 ServerNetBackup-1 2 1/1 OK
2014-12-29 10:42:35 client2.org /data2 1 ServerNetBackup-2 1 1/1 OK
2015-01-05 11:07:51 client2.org /data2 0 ServerNetBackup-3 2 1/1 OK

3.选择一个客户端来还原数据

用法
Usage: amfetchdump [options] config hostname [diskname [datestamp [level [hostname [diskname [datestamp [level ... ]]]]]]] [-o configoption]*
还原客户端1的数据
amfetchdump ServerNetBackup client1 /home/data 20141225172132

4.查看还原目录下的数据

-bash-4.1$ ll
total 28232
-rw-r----- 1 amandabackup disk 28907520 Jan 8 16:29 client1._home_data.20141225172132.0
得到还原数据的格式是一个tar压缩包(这是在备份时已经定义好的备份格式)
-bash-4.1$ file client1._home_data.20141225172132.0
client1._home_data.20141225172132.0: POSIX tar archive

5.对文件解压缩

tar xf client1._home_data.20141225172132.0
返回如下:
-rw-r----- 1 amandabackup disk 28907520 Jan 8 16:29 client1._home_data.20141225172132.0
-rw-r--r-- 1 amandabackup disk 28898417 Dec 25 17:21 Python-2.7.3-1.x86_64_mccq6.2.rpm

五、Amanda的优缺点

amanda的优点

1.Amanda的安装和操作都非常简单。它提供了rpm安装包和tar安装包,根据它的安装手 册,可以在15分钟安装完成一台服务器和三台客户端。安装完成之后,不需要更多的操作。 恢复也只需要使用amrecover盯这一条命令即可。

2.Amanda可以根据数据的更新速度,选择不同的备份频率,可以选择每天备份或者每周 备份。

3.采用c/s模式,安全性较好。恢复时,只需要在客户端进行操作,不会改变服务 器上的备份文件.

4.Amanda兼容性很好,它支持windows系统和多种Linux系统。服务器能够识别到的磁 带驱动器,Amanda就可以直接使用。

5.Amanda使用的备份程序是Linux自带的tar和dump,一旦Amanda本身出现问题,也可 以用tar或者restore这些标准Linux命令恢复文件。

6.Amanda的备份列表定义在disklist文件中,便于添加或者删除需要备份的数据.

7.Amanda支持同时写入磁盘和磁带,实现了在线和离线两种保存方式,提高了容灾性。

8.Amanda使用磁盘作为备份文件的缓存区,这样既优化了磁带的写入性能,也保证了在 磁带出错时也能备份数据。Amanda支持并行数据传输,可提高备份速度。

9.Amanda是免费软件,但是有自己的支持团队。在Amanda wiki里面提供了很多Amanda相关文档。

以上amanda的优点来自《基于Amanda的数据备份与恢复技术》 姚秋玲 (中科院高能物理研究所计算中心,北京,100049)

Amanda的缺点(也并不能算是缺点,只是不适合当前的项目而已)

1.Amanda是网络集中备份系统,对网络的依赖性比较强

2.在客户端没有生成一个备份,当数据需要恢复时,需要从服务器端拉取备份,如果当前的网络质量不好,恢复数据的时间会比较久

3.Amanda的备份列表在服务器端disklist文件中定义,当添加新的备份时需要维护这份文件列表

4.对服务器端的性能要求相对较高

5.服务器端的虚拟磁带需要规划好,如果备份的数据大小比设定的虚拟磁带的要大,数据会备份错误

6.当前需要备份的机器和机器需要备份的目录相对较多,如果备份集中到一台服务器上,管理起来会比较混乱,当然,对于需要备份的机器较少的情况,是可行的

转载于:https://blog.51cto.com/8721349/1601006

Amanda之安装、部署、测试以及优缺点相关推荐

  1. node.js安装部署测试

    (一)安装配置: 1:从nodejs.org下载需要的版本 2:直接安装,默认设置 ,默认安装在c:\program files\nodejs下. 3:更改npm安装模块的默认目录 (默认目录在安装目 ...

  2. presto联合查询mysql和ES_presto-mysql/elasticsearch6.0.0安装部署测试,异种数据源关联查询入门实践...

    本文简单记录一次实践使用过程,涉及presto-mysql,presto-elasticsearch,文中参数未做注释,请参考官方文档,希望能帮到大家 1 下载安装 presto-0.228 < ...

  3. hadoopHA安装部署测试

    hadoop,spark,kafka交流群:224209501 标签(空格分隔): hadoop 本文主要完成以下内容: 1) HDFS HA(高可用性)原理(把握四大要点),最好自己作图 2) 依据 ...

  4. itop在Linux部署环境,iTop的安装部署-测试环境的安装配置- iTop软件安装

    本帖最后由 adminlily 于 2020-12-24 09:29 编辑 软件下载 iTop软件可以在网上搜索找到,或到www.itilxf.com社区下载,也可以直接在QQ群的共享里下载,群号是2 ...

  5. Ubuntu中安装部署Intel CS WebRTC

    0.引言 研究Intel CS WebRTC时,需要搭建环境,按官网或网上找到的文档进行搭建都发现有各种问题,由于相关资料比较少,不好进行排查解决. 本文将最终部署成功的部署进行说明,希望对后来者能有 ...

  6. 安装部署(七) HBase集群安装部署与测试

    HBase集群安装部署与测试 Hadoop 2.7.2  Spark 2.0.0 Kafka 0.10.0.0 HBase 1.2.2 Zookeeper 3.4.8 参考: http://www.t ...

  7. 安装黑群晖找不到局域网电脑_UNRAID 、黑群晖、 穿越派 私有云部署测试

    小白业余时间.趁年轻折腾折腾私有云.NAS (在此提醒大家多支持正版,本人只是用来测试) 小白找到了 UNRAID欢乐版,感谢各位大神的杰作.找U盘.准备工具包. UNRAID制作U盘启动失败 U盘读 ...

  8. 测试环境docker-swarm安装部署

    测试环境swarm安装部署 部署前增加监听docker2375端口 centos 增加tcp监听端口 修改/lib/systemd/system/docker.service sed -i 's/Ex ...

  9. weblogic测试环境安装部署--傻瓜式安装教程

    测试环境weblogic部署手册 1.weblogic需要有jdk环境 1.1 通过xftp工具把jdk1.8的软件包传入到服务器的/usr/local中并解压 cd /usr/local tar - ...

最新文章

  1. 计算机评语公式怎么输,在excel中,如何使用公式写评语
  2. STM32使用DMA从串口读数据到内存
  3. python的GUI库PyQt5的使用
  4. python的setting怎么找_python-DJANGO_SETTINGS_MODULE如何配置
  5. 怎么打开python shell_Python之使用adb shell命令启动应用的方法详解
  6. Asp.Net Mvc3.0(MEF依赖注入实例)
  7. php=与-,谈谈PHP中的 -、= 和 :: 符号
  8. css 两边宽度固定中间自适应宽度
  9. 12天背诵楞严咒的技巧_背诵楞严咒的技巧
  10. 谷歌浏览器js报错:Uncaught (in promise) DOMException
  11. 浅谈GRADS气象绘图软件的使用
  12. unity 简易游戏打飞碟V2
  13. android实训总结ppt模板,ppt制作实训心得.docx
  14. matlab usb采集,求助MATLAB是否支持USB数据采集卡
  15. 手机端网页-微信授权登录
  16. 《.NET程序员面试秘籍》读书笔记
  17. 我的世界win10java_我的世界java版和win10版的区别
  18. 如何快速增加NFC能力到任何应用程序
  19. 联邦学习攻击与防御综述
  20. FlyAI资讯:关于Transformer,那些的你不知道的事

热门文章

  1. js Dom对象的属性与方法
  2. 图解JVM内存三大核心区域及其JVM内存案例实战剖析
  3. 通过Jinq简化数据库查询
  4. Android学习之适配器SimpleCursorAdapter
  5. 域内计算机策略应用顺序
  6. iOS网络编程实践--蓝牙对等网络通信实例讲解
  7. 侧栏广告 image flash
  8. LeetCode 73. Set Matrix Zeroes
  9. 【字符串替换】程序员面试金典——1.5基本字符串压缩
  10. 剑指offer——面试题33:把数组排成最小数