参考:

https://wenku.baidu.com/view/881e0c998e9951e79a892759.html

yum  -y  install  amanda*

http://blog.51cto.com/13525470/2060765

yum  -y  install  xinetd*

https://linux.die.net/man/7/amanda-auth

http://blog.51cto.com/8721349/1601006

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

http://blog.51cto.com/8721349/1601006

一、前言

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

CentOS7安装配置Amanda的更多相关文章

  1. Centos7安装配置gitlab

    Centos7安装配置gitlab 这篇文字我会介绍在Centos7上安装gitlab,配置gitlab的smtp,并且创建项目demo. sudo yum install openssh-serve ...

  2. Centos7安装配置Apache+PHP+Mysql+phpmyadmin

    转载自: Centos7安装配置Apache+PHP+Mysql+phpmyadmin 一.安装Apache yum install httpd 安装成功后,Apache操作命令: systemctl ...

  3. Centos7安装配置JDK8

    Centos7安装配置JDK8 一.准备工作 第一步,去甲骨文官网下载Jdk相应的版本,我这里下载的是jdk1.8. 第二步将你从官网上下载下来的jdk使用FTP工具上传到云服务器上的相应目录,我的是 ...

  4. centos7命令行和图形界面的相互切换(附centos7安装配置教程)

    一.最近安装了centos7,发现在命令行和图形界面的相互切换命令上,与centos以往版本有很大不同,先整理如下,加深记忆. 1,centos7默认安装后,跟其他版本一样,启动默认进入图形界面: 2 ...

  5. (转)Centos7安装配置NFS服务和挂载

    Centos7安装配置NFS服务和挂载 原文:https://www.u22e.com/601.html NFS简介 NFS(Network File System)即网络文件系统,是FreeBSD支 ...

  6. CentOS7 安装配置笔记

    CentOS7 安装配置笔记 1.通过镜像安装 CentOS7 ==============================* 使用 UltraISO 9.7 或者 rufus-3.5p 制作ISO的 ...

  7. Centos7安装配置jenkins(Tomcat)

    Centos7安装配置jenkins(Tomcat) 一.准备工作 1.1 安装JDK1.8 具体安装过程不在赘述. 1.2 下载jenkins的war包 jenkins官网下载地址:https:// ...

  8. CentOS7 安装配置rsync

    centos7自带rsync,今天简单记录下. rsync安装配置步骤 服务器端: 1.修改默认配置文件/etc/rsyncd.conf,该成如下: # /etc/rsyncd: configurat ...

  9. centos7安装配置zabbix4.0

    zabbix01    198.8.8.211    zabbix-server4.0 zabbix02    198.8.8.212    zabbix-agent4.0 一:zabbix服务端环境 ...

随机推荐

  1. tigervnc-server安装使用

    root/finance, hm/finance   一,安装tigervnc-server VNC软件包 [root@localhost ~]# yum install tigervnc-serve ...

  2. Post四种Content-Type

    application/x-www-form-urlencoded 这应该是最常见的 POST 提交数据的方式了.浏览器的原生 form 表单,如果不设置 enctype 属性,那么最终就会以 app ...

  3. 在linux中要直接查找的命令

  4. Linux中常用压缩打包工具

    Linux中常用压缩打包工具 压缩打包是常用的功能,在linux中目前常用的压缩工具有gzip,bzip2以及后起之秀xz.本文将介绍如下的工具常见压缩.解压缩工具以及打包工具tar. gzip2 直 ...

  5. 外网teamview连接不上服务器teamview的错误: 一直显示正在连接,正在初始化显示参数的

    一.错误 错误:  服务器的TV已打开,外网连接服务器TV,一直显示正在连接,正在初始化显示参数的原因. 二. 分析原因: 1. teamview简介TV 2. 服务器必须要开一个远程端口,意思是必须 ...

  6. 四则运算web最终版

    经过若干时间的奋战,终于完成了web版四则运算程序.团队成员:井小普.张贺. 设计思想: 在之前的程序基础上两人结合开发web系统. 首先,进行登录注册界面的编写,不同用户,对应不同的错题库,答题记录 ...

  7. C++的面试题

    1.什么是类? 类是具有相同属性和相同的方法的对象的集合,它是一种既包含数据又包含函数的抽象数据类型. 对象是类进行实体化后的产物,是一个实体. 在C++中也是先声明一个类类型,用类去定义若干个同类型 ...

  8. MongoDB\BSON\UTCDateTime::toDateTime

    示例# 1 MongoDB \ BSON \ UTCDatetime:toDateTime()例子 <?php $utcdatetime = new MongoDB\BSON\UTCDateTi ...

  9. Python标准数据类型的二次加工

    基于类继承的原理实现: class Li(list): #继承标准数据类型 list def app(self,p_object): #派生出新的 append功能 if not isinstance ...

  10. 思科恶意加密TLS流检测论文记录——由于样本不均衡,其实做得并不好,神马99.9的准确率都是浮云啊,之所以思科使用DNS和http一个重要假设是DGA和HTTP C&C(正常http会有图片等)。一开始思科使用的逻辑回归,后面17年文章是随机森林。

    论文记录:Identifying Encrypted Malware Traffic with Contextual Flow Data from:https://songcoming.github. ...