Tuesday, May 20, 2008

Amanda Setup in Ubuntu 7.10 with VirtualTapes

What is Amanda?

AMANDA, the Advanced Maryland Automatic Network Disk Archiver, is a backup system that allows the administrator to set up a single master backup server to back up multiple hosts over network to tape drives/changers or disks or optical media. Amanda uses native dump and/or GNU tar facilities and can back up a large number of workstations running multiple versions of Unix.

This will guide you through setting up virtual tapes (utilizing hard disk space for backups)

Install and edit xinetd


Create an amanda xinetd entry
If you haven't already installed xinetd, install it
Code:
sudo apt-get install xinetd
Create an amanda xinetd entry
Code:
sudo vim /etc/xinetd.d/amanda
Give it the following contents
Code:
# default: on
# description: The amanda service
service amanda
{
only_from = kcs.keltron.org
disable = no
socket_type = dgram
protocol = udp
wait = yes
user = backup
group = backup
groups = yes
server = /usr/lib/amanda/amandad
server_args = -auth=bsd amdump amindexd amidxtaped
}
service amandaidx
{
socket_type = stream
protocol = tcp
wait = no
user = backup
group = backup
groups = yes
server = /usr/lib/amanda/amindexd
disable = no
}
service amidxtape
{
socket_type = stream
protocol = tcp
wait = no
user = backup
group = backup
groups = yes
server = /usr/lib/amanda/amidxtaped
disable = no








}

Install the AMANDA Server

Install AMANDA and dependencies
Code:
sudo apt-get install amanda-server
Restart xinetd
Code:
sudo /etc/init.d/xinetd restart
Become "backup" user
Code:
su backup
Create copies of the configuration files, just in case
Code:
cp -R /etc/amanda/DailySet?1 /etc/amanda/DailySet?1.bak
Edit amanda.conf

Let's get in and edit the amanda.conf
Code:
vim /etc/amanda/DailySet?1/amanda.conf
Make the following changes in the file
Code:
org “"
mailto ", "
tpchanger "chg-disk"
changerfile "/etc/amanda/daily/changer"
tapedev "file:/amandabackup/DailySet?1/slots"
tapetype HARDDISK
#tapetype HP-DAT <--- comment this out
#labelstr "^HISS[0-9][0-9]*$" <--- comment this out
amrecover_do_fsf yes
amrecover_check_label yes
amrecover_changer "changer"
define tapetype HARDDISK {

length mbytes
}










Edit disklist

The format for the disklist file is :
Dumptypes are deinfed in /etc/amanda/amanda.conf, but we'll use the GNUTAR dumptype "comp-user-tar" for this example

Let's get in and edit the disklist
Code:
vim /etc/amanda/DailySet?1/disklist
Add a line like so
Code:
kcs.keltron.org /Project comp-user-tar


kcs.keltron.org /clientbackup comp-user-tar
What this line is telling AMANDA is that when it attempts to do a dump that it should connect to kcs.keltron.org, backup the directory /project and /clientbackup and user the options that are defined in amanda.conf for the "comp-user-tar" dumptype.
Create Virtual Tapes

Choose a location for your tapes to reside;Here we using /amandabackups/

Create the tapelist file that is necessary for indexing tapes available
Code:
touch /etc/amanda/DailySet?1/tapelist
Create the location and set permissions for the virtual tapes
Code:
mkdir -p -m 770 /amandabackup/DailySet?1/slots


chown -R backup:backup /amdndahosts
CD to the new directory
Code:
cd /amandabackup/DailySet?1/slots
Create the necessary directories for the tapes
Code:
for (i=1; $i<=25; i++)?; do mkdir slot$i; done
Create symlink for the data directory to point to the first tape
Code:
ln -s slot1 data
Test the vtapes to be sure that we get an ONLINE message
Code:
ammt -f file:/amandabackup/DailySet?1/slots status
Label the tapes
Code:
for (i=1; $i<=9; i++)?; do amlabel DailySet?1 DailySet?1-0$i slot $i; done
Code:
for (i=10; $i<=25; i++)?; do amlabel DailySet?1 DailySet?1-$i slot $i; done

Output should look like (for each slot)
Code:
labeling tape in slot 1 (file:/amandabackup/DailySet?1/slots):

rewinding, reading label, not an amanda tape


rewinding, writing label DailySet?1-01, checking label, done.
Reset the changer back to slot 1
Code:
amtape DailySet?1 reset

Output should look like
Code:
amtape: changer is reset, slot 1 is loaded.
Edit .amandahosts

On Ubuntu the .amandahosts file is located as /etc/amandahosts

Open the file
Code:
vim /etc/amandahosts
The file looks like
Cod
localhost backup
localhost root amindexd amidxtaped
kcs.keltron.org backup

kcs.keltron.org backup amindexd amidxtaped


kcs.keltron.org root amindexd amidxtaped
On the Client

Here We are using two clients one is gis.keltron.org and another one is the same amdanda server kcs.keltron.org.

Install AMANDA client

Install the AMANDA client app
Code:
sudo apt-get install amanda-client
Create necessary amanda directory ( It is not needed for the server kcs.keltron.org)
Code:
sudo mkdir -p -m 770 /etc/amanda
Change owner
Code:
sudo chown -R backup.backup /etc/amanda
Become the backup user
Code:
su backup
Create an excludes file
Code:
touch /etc/amanda/exclude.gtar
Edit /etc/amandahosts to allow server to connect to client machine for backups
Code:
localhost backup

gis.keltron.org backup


kcs.keltron.org backup
Create xinetd amanda entry
Code:
sudo vim /etc/xinetd.d/amanda
Edit the file, mine looks like
Code:
# default: on
#
# description: Amanda services for Amanda client.
#
service amanda
{
bind = gis.keltron.org
socket_type = dgram
protocol = udp
wait = yes
user = backup
group = backup
groups = yes
server = /usr/lib/amanda/amandad
server_args = -auth=bsd amdump

disable = no


}
Each of these lines is very important. The "bind" line will probably not be necessary for most configurations - this is in place because I have 2 different IP addresses binding to the same device (eth0 aliases).

Restart xinetd
Code:
sudo /etc/init.d/xinetd restart
Edit /etc/services to look like
Code:
#
# Amanda Services
#
amanda 10080/udp
amanda 10080/tcp
kamanda 10081/udp
kamanda 10081/tcp

amandaidx 10082/tcp


amidxtape 10083/tcp
Make sure your /etc/inetd.conf looks like
Code:
amanda dgram udp wait backup /usr/sbin/tcpd /usr/lib/amanda/amandad
On the Server

Verify Configuration

Run amcheck on Server to verify configuration files, connections, etc lgoin as backup user
Code:
amcheck DailySet?1

Output looks like
Cod
backup@kcs:~$ amcheck DailySet?1
Amanda Tape Server Host Check



Holding disk /dumps/amanda: 4478364 KB disk space available, using 4375964 KB
slot 2: read label `DailySet?1-02', date `X'
NOTE: skipping tape-writable test
Tape DailySet?1-02 label ok
Server check took 0.112 seconds

Amanda Backup Client Hosts Check




Client check: 2 host checked in 0.017 seconds, 0 problems found


(brought to you by Amanda 2.5.1p3)

Amrecover

amrecover — Amanda index database browser

Amrecover browses the database of Amanda index files to determine which tapes contain files to recover. Furthermore, it is able to recover files.

In order to restore files in place, you must invoke amrecover from the root of the backed up filesystem, or use lcd to move into that directory, otherwise a directory tree that resembles the backed up filesystem will be created in the current directory. See the examples below for details.

Amrecover should be run as root user.

Amrecover will the read the amanda-client.conf file and the config/amanda-client.conf file. If no configuration name is supplied on the command line, Amrecover will try the compiled-in default configuration, usually DailySet?1.


Edit the following lines in amanda-client.conf

conf "DailySet?1" # your config name

index_server "kcs.keltron.org" # your amindexd server
tape_server "kcs.keltron.org" # your amidxtaped server
tapedev "file:/amandabackup/DailySet?1/slots" # your tape device

Example
oot@kcs:~# amrecover
AMRECOVER Version 2.5.1p3. Contacting server on localhost ...
220 kcs AMANDA index server (2.5.1p3) ready.
Setting restore date to today (2008-04-22)
200 Working date set to 2008-04-22.
200 Config set to DailySet?1.
200 Dump host set to kcs.keltron.org.
Use the setdisk command to choose dump disk to recover
amrecover> ls
Must select a disk before listing files; use the setdisk command.
amrecover> help
valid commands are:

add path1 ... - add to extraction list (shell wildcards)
addx path1 ... - add to extraction list (regular expressions)
cd directory - change cwd on virtual file system (shell wildcards)
cdx directory - change cwd on virtual file system (regular expressions)
clear - clear extraction list
delete path1 ... - delete from extraction list (shell wildcards)
deletex path1 ... - delete from extraction list (regular expressions)
extract - extract selected files from tapes
exit
help
history - show dump history of disk
list [filename] - show extraction list, optionally writing to file
lcd directory - change cwd on local file system
ls - list directory on virtual file system
lpwd - show cwd on local file system
mode - show the method used to extract SMB shares
pwd - show cwd on virtual file system
quit
listhost - list hosts
listdisk [diskdevice] - list disks
setdate {YYYY-MM-DD|--MM-DD|---DD} - set date of look
{YYYY-MM-DD-HH-MM-SS} - set date of look
setdisk diskname [mountpoint] - select disk on dump host
sethost host - select dump host
settape [host:][device|default] - select tape server and/or device
setmode smb|tar - select the method used to extract SMB shares

amrecover> listhost
200- List hosts for config DailySet?1
201- kcs.keltron.org
200 List hosts for config DailySet?1
amrecover> listdisk
200- List of disk for host kcs.keltron.org
201- /Project
200 List of disk for host kcs.keltron.org
amrecover> setdisk /Project /Documents
200 Disk set to /Project.
amrecover> lpwd
/root
amrecover> ls
2008-04-22 sajithvk/
2008-04-22 new/
2008-04-22 myproject/
2008-04-22 lost+found/
2008-04-22 jayapal_vip_simulation/
2008-04-22 jayapal_itbg_search/
2008-04-22 jayapal_callcenter/
2008-04-22 careers/
2008-04-22 callcenter/
2008-04-22 binsun/
2008-04-22 .
amrecover> add myproject
Added dir /myproject/ at date 2008-04-22
amrecover> lpwd
/root
amrecover> extract

Extracting files using tape drive @DEFAULT_TAPE_DEVICE@ on host localhost.
The following tapes are needed: DailySet?1-01

Restoring files into directory /root
Continue [?/Y/n]? y

Extracting files using tape drive @DEFAULT_TAPE_DEVICE@ on host localhost.
Load tape DailySet?1-01 now
Continue [?/Y/n/s/t]? y
Label mismatch, got DailySet?1-02 and expected DailySet?1-01
Looking for tape DailySet?1-01...
./myproject/
./myproject/.bzr/
./myproject/.bzr/branch/
./myproject/.bzr/branch-lock/
./myproject/.bzr/branch/lock/
./myproject/.bzr/repository/
./myproject/.bzr/repository/knits/
./myproject/.bzr/repository/lock/
./myproject/.bzr/repository/revision-store/
./myproject/.bzr/README
./myproject/.bzr/branch-format
./myproject/.bzr/branch/branch-name
./myproject/.bzr/branch/format
./myproject/.bzr/branch/revision-history
./myproject/.bzr/repository/format
./myproject/.bzr/repository/inventory.kndx
./myproject/.bzr/repository/inventory.knit
./myproject/.bzr/repository/revisions.kndx
./myproject/.bzr/repository/revisions.knit
./myproject/.bzr/repository/signatures.kndx
./myproject/.bzr/repository/signatures.knit
amrecover> quit
200 Good bye.

No comments: