Tuesday, July 13, 2010

Centralized Backup Server With Amanda On CentOS

SkyHi @ Tuesday, July 13, 2010

This document describes how to set up a centralized network backup with Amanda. We will use virtual tape to store the backup.

In my environment, I have 2 Linux servers that I want to backup. (Alpha) : /home/kulathep (Beta) : /data and /var

I am going to build a new server with Amanda as a centralized backup server. (Gamma)

Setup Server (Gamma)

1. Install Amanda with yum:

yum -y install amanda*

2. Edit Amanda conf in xinetd.d:

vi /etc/xinetd.d/amanda

vi /etc/xinetd.d/amandaidx

vi /etc/xinetd.d/amidxtape

Change Disable = yes to Disable = no.

3. Copy Amanda conf files:

cp -r /etc/amanda/DailySet1 /etc/amanda/intra

4. Edit amanda.conf:

vi /etc/amanda/intra/amanda.conf

org “Configuration name”

mailto “email”

netusage 600 Kbps

dumpcycle 2 weeks

runspercycle 10

tapecycle 15 tapes

#tpchanger “chg-manual”

tpchanger “chg-disk”

changerfile “/etc/amanda/intra/changer”

#tapedev “null:”

tapedev “file:/backup/intra/slots”

#tapetype HP-DAT

#labelstr “^DailySet1-[0-9][0-9]*$”

tapetype HARDDISK

define tapetype HARDDISK {

comment “Backup to Virtual Tape”

length 3072 mbytes # each tape is 3 Gigs


# amrecover_changer “null:”

amrecover_changer “changer”

#infofile “/etc/amanda/DailySet1/curinfo” # database DIRECTORY

#logdir “/etc/amanda/ DailySet1″ # log directory

#indexdir “/etc/amanda/ DailySet1/index” # index directory

infofile “/var/log/amanda/intra/curinfo” # database DIRECTORY

logdir “/var/log/amanda/intra” # log directory

indexdir “/var/log/amanda/intra/index” # index directory

With this configuration, Amanda will do a full backup every 2 weeks, and an incremental backup every week day. The backup will be stored and rotated on 15 virtual tapes.

5. Edit disklist (tell Amanda which servers, directory to backup, what dumptype to use).

vi /etc/amanda/intra/disklist

Remove every lines including “localhost /etc comp-root-tar” at the end of the file. And add:

alpha /home/kulathep comp-user-tar

beta /data comp-user-tar

beta /var comp-user-tar

Note: See amanda.conf for the dumptype.

6. Edit hosts file:

vi /etc/hosts

Add: alpha beta

7. Create backup directory (we will store the backup here):

mkdir -p -m 770 /backup/intra/slots

chown -R amanda:disk /backup

8. Create tape list:

touch /etc/amanda/intra/tapelist

chown –R amanda:disk /etc/amanda/intra

9. Create slots (virtual tapes):

su - amanda

cd /backup/intra/slots

for ((i=1; $i<=15; i++)); do mkdir slot$i; done

ln -s slot1 data

10. Test virtual tapes:

/usr/sbin/ammt -f file:/backup/intra/slots status

11. Label the virtual tapes:

for ((i=1; $i<=15; i++)); do /usr/sbin/amlabel intra intra-$i slot $i; done

12. Reset the tape:

/usr/sbin/amtape intra reset

13. Edit .amandahosts to allow communications from clients:

vi /var/lib/amanda/.amandahosts

alpha amanda

beta amanda

gamma amanda

14. Start xinetd service:

su –

service xinetd start

15. Check amanda process:

lsof | grep amanda

Set Up Client

1. Install amanda client with yum:

yum -y install amanda-client

2. Edit file .amandahosts to allow communications from server:

vi /var/lib/amanda/.amandahosts

gamma amanda

3. Edit xinetd.d:

vi /etc/xinetd.d/amanda

Disable = no

4. Start xinetd:

service xinetd start

5. Check Amanda service:

lsof | grep amanda

Backup Data

1. Check tapes and clients on server:

su - amanda

/usr/sbin/amcheck intra

2. Dump manually:

/usr/sbin/amdump intra

3. Add amdump to cron:

crontab –e

0 16 * * 1-5 /usr/sbin/amcheck -m intra

45 0 * * 2-6 /usr/sbin/amdump intra

The first line checks the tape/clients and sends an email if it found something wrong (no email if everything is okay) at 4pm.

The second line dumps at 12.45am on weekdays.

Restore Data

1. Prepare tapes:

cd /tmp

/usr/sbin/amtape intra slot 1 # select slot1 (tape1)

/usr/sbin/ammt -t file:/backup/intra/slots rewind # rewind

2.1. Restore everything from every server:

/usr/sbin/amrestore file:/backup/intra/slots

2.2. Restore only a server and a directory:

/usr/sbin/amrestore file:/backup/intra/slots beta /var

3. Extract:

tar xvf <Restored files>