Installazione e configurazione Amanda su Debian Sarge

From RVM Wiki
Jump to navigation Jump to search

Installazione pacchetti

apt-get install amanda-client amanda-common amanda-server


Configurazione accessi

cat >/etc/amandahosts <<EOFile
# nomehost utente_che_può_accedere
localhost                 root
localhost.localdomain     root
localhost                 backup
localhost.localdomain     backup
$(hostname)               root
$(hostname -f)            root
$(hostname)               backup
$(hostname -f)            backup
EOFile


Configurazione principale

In /etc/amanda c'è una cartella DailySet1, che contiene gli esempi per il Job così denominato.

Modificare quanto segue in /etc/amanda/DailySet1/amanda.conf:

org "Nome Server per Report"         # your organization name for reports
mailto "alert@rvmgroup.it"           # space separated list of operators at your site

dumpcycle 0             # the number of days in the normal dump cycle
tapecycle 1 tapes       # the number of tapes after that a tape could be overwritten
                        # con 1 si può sovrascrivere qualsiasi nastro successivo

tapedev "/dev/nst0"     # Linux @ tuck, important: norewinding


Definizione del tipo di nastro

Bisogna definire un tipo nastro, da utilizzare poi nella configurazione.

Identificare il tape drive in uso:

# cat /proc/scsi/scsi
Attached devices:
Host: scsi0 Channel: 00 Id: 03 Lun: 00
  Vendor: HP       Model: C5683A           Rev: C104
  Type:   Sequential-Access                ANSI SCSI revision: 02

Verificare che non sia già esistente nel file di configurazione. Se non esiste, cercarlo nelle FAQ di amanda http://amanda.sourceforge.net/cgi-bin/fom?cmd=searchForm&file=1 oppure su google.

Esempi:

HP Dat 8i C1533A

4 Gb non compressi DDS2

define tapetype C1533A_120 {
    comment "HP C1533A DDS2 with 120m tapes"
    length 3858 mbytes
    filemark 107 kbytes
    speed 507 kbytes
}


HP Dat 40i C5683A

20 Gb non compressi DDS4

define tapetype HP-Dat-40-C5683A {
    comment "HP Surestore Dat40i C5683A"
    length 19560 mbytes
    filemark 1147 kbytes
    speed 2957 kps
} 


HP Dat 160

78 Gb non compressi DD6

define HP-DAT160 {
    comment "HP StorageWorks DAT 160)"
    length 78236 mbytes
    filemark 4461 kbytes
    speed 6272 kps
}


Mettere la definizione prima delle altre.

Definire ora che per questo job si intente usare questo tapetype.

In /etc/amanada/DailySet1/amamnda.conf:

tapetype HP-Dat-40-C5683A             # what kind of tape it is (see tapetypes below)

Definizione del Formato della Label per i nastri

Occorre definire un formato standard per verificare che il tape inserito sia effettivamente uno giusto.

Per standard utiliiamo il formato

A-01-Monday

Quindi modificare in /etc/amanada/DailySet1:

labelstr "^[A-Z]-[0-5][0-5]-$*" # label constraint regex: all tapes must match


Definizione del tipo di Job di Backup

Occorre definire le caratteristiche del dumptype. Utiliziamo un backup completo giornaliero che utilizzi il formato portabile tar compresso.

Modificare in /etc/amanada/DailySet1:

define dumptype always-full {
    comment "Full dump using tar with best software compression"
    program "GNUTAR"
    options compress-best, index
    priority high
    dumpcycle 0
    maxcycle 0
}

Il dumptype sarà poi assegnato ad ogni disco in seguito.


Definizione dei dischi da backuppare

Occorre definire che dischi backuppare e in che modo.

Editare /etc/amanda/DailySet1/disklist. Se la partizione e il disco è uno solo, usare:

cat > /etc/amanda/DailySet1/disklist <<EOFile
# File format is:
#       hostname diskdev dumptype
# where the dumptypes are defined by you in amanda.conf.

#$(hostname) $(mount | grep 'on / ' | cut -f 1 --delim=' ') always-full
$(hostname) /bin always-full
#nomeserver disco dumptype
EOFile

Dall'esempio risulterà:

# File format is:
#       hostname diskdev dumptype
# where the dumptypes are defined by you in amanda.conf.

#server /dev/md0 always-full
server /bin always-full
#nomeserver disco dumptype

In questo caso quando si eseguirà il Job DailiSet1, verrà backuppato il disco /dev/md0 utiliando la configurazione test definita precedentemente. In produzione si utilizzerà la configurazione always-full.


Etichettatura dei Nastri

Si procede all'etichettatura dei nastri, in modo da identificarli univocamente. L'etichettatura va eseguita come utente "backup"

Crezione della tapelist vuota:

su backup -c "touch /etc/amanda/DailySet1/tapelist"

Etichettatura del nastro di backup manuale

su backup -c "/usr/sbin/amlabel DailySet1 X-01-Manual"
rewinding, reading label, not an amanda tape
rewinding, writing label X-01-Manual, checking label, done.

Verifica dell'inserimento in tapelist:

cat tapelist
0 X-01-Manual reuse

Verifica della lettura della label

su backup -c "/usr/sbin/amcheck DailySet1"
Amanda Tape Server Host Check
-----------------------------
NOTE: skipping tape-writable test
Tape X-01-Manual label ok
NOTE: info dir /var/lib/amanda/DailySet1/curinfo: does not exist
NOTE: it will be created on the next run
NOTE: index dir /var/lib/amanda/DailySet1/index/allserver: does not exist
Server check took 0.499 seconds

Amanda Backup Client Hosts Check
--------------------------------
Client check: 1 host checked in 0.645 seconds, 0 problems found

(brought to you by Amanda 2.4.4p3)

Quando è tutto ok, si procede al label di tutti i nastri, automatizzando anche l'espulsione:

su backup -c "/usr/sbin/amlabel DailySet1 A-01-Monday" ; ammt -f /dev/nst0 rewoffl
rewinding, reading label, not an amanda tape
rewinding, writing label A-01-Monday, checking label, done.


Test configurazione

su backup -c "/usr/sbin/amcheck DailySet1"
Amanda Tape Server Host Check
-----------------------------
NOTE: skipping tape-writable test
Tape X-01-Manual label ok
NOTE: info dir /var/lib/amanda/DailySet1/curinfo: does not exist
NOTE: it will be created on the next run
NOTE: index dir /var/lib/amanda/DailySet1/index/allserver: does not exist
Server check took 0.024 seconds

Amanda Backup Client Hosts Check
--------------------------------
Client check: 1 host checked in 0.032 seconds, 0 problems found

(brought to you by Amanda 2.4.4p3)


Backup di test

Come utente backup lanciare il backup in background ed osservare il log:

su backup -c '/usr/sbin/amdump DailySet1 &'
tail -f /var/log/amanda/DailySet1/amdump


Questo è un log di esempio del backup di test corretto:

cat /var/log/amanda/DailySet1/amdump.1

amdump: start at Fri Jun  3 14:00:12 CEST 2005
amdump: datestamp 20050603
planner: pid 9238 executable /usr/lib/amanda/planner version 2.4.4p3
planner: build: VERSION="Amanda-2.4.4p3"
planner:        BUILT_DATE="Wed Aug 18 13:06:52 MDT 2004"
planner:        BUILT_MACH="Linux rover 2.6.7 #1 Fri Jul 23 21:53:49 MDT 2004 i686 GNU/Linux"
planner:        CC="gcc"
planner:        CONFIGURE_COMMAND="'./configure' '--prefix=/usr' '--bindir=/usr/sbin' '--mandir=/usr/share/man' '--libexecdir=/usr/lib/amanda' '--enable-shared' '--sysconfdir=/etc' '--localstatedir=/var/lib' '--with-gnutar-listdir=/var/lib/amanda/gnutar-lists' '--with-index-server=localhost' '--with-user=backup' '--with-group=backup' '--with-bsd-security' '--with-amandahosts' '--with-smbclient=/usr/bin/smbclient' '--with-tcpportrange=50000,50100' '--with-udpportrange=840,860'"
planner: paths: bindir="/usr/sbin" sbindir="/usr/sbin"
planner:        libexecdir="/usr/lib/amanda" mandir="/usr/share/man"
planner:        AMANDA_TMPDIR="/tmp/amanda" AMANDA_DBGDIR="/tmp/amanda"
planner:        CONFIG_DIR="/etc/amanda" DEV_PREFIX="/dev/"
planner:        RDEV_PREFIX="/dev/" DUMP="/sbin/dump"
planner:        RESTORE="/sbin/restore" VDUMP=UNDEF VRESTORE=UNDEF
planner:        XFSDUMP="/sbin/xfsdump" XFSRESTORE="/sbin/xfsrestore"
planner:        VXDUMP=UNDEF VXRESTORE=UNDEF
planner:        SAMBA_CLIENT="/usr/bin/smbclient" GNUTAR="/bin/tar"
planner:        COMPRESS_PATH="/bin/gzip" UNCOMPRESS_PATH="/bin/gzip"
planner:        LPRCMD="/usr/bin/lpr" MAILER="/usr/bin/Mail"
planner:        listed_incr_dir="/var/lib/amanda/gnutar-lists"
planner: defs:  DEFAULT_SERVER="localhost" DEFAULT_CONFIG="DailySet1"
planner:        DEFAULT_TAPE_SERVER="localhost"
planner:        DEFAULT_TAPE_DEVICE="/dev/null" HAVE_MMAP HAVE_SYSVSHM
planner:        LOCKING=POSIX_FCNTL SETPGRP_VOID DEBUG_CODE
planner:        AMANDA_DEBUG_DAYS=4 BSD_SECURITY USE_AMANDAHOSTS
planner:        CLIENT_LOGIN="backup" FORCE_USERID HAVE_GZIP
planner:        COMPRESS_SUFFIX=".gz" COMPRESS_FAST_OPT="--fast"
planner:        COMPRESS_BEST_OPT="--best" UNCOMPRESS_OPT="-dc"
planner: time 0.000: dgram_bind: socket bound to 0.0.0.0.859
READING CONF FILES...
driver: pid 9239 executable /usr/lib/amanda/driver version 2.4.4p3
driver: tape size 20029440
driver: send-cmd time 0.002 to taper: START-TAPER 20050603
taper: pid 9240 executable taper version 2.4.4p3
driver: started dumper0 pid 9241
driver: started dumper1 pid 9242
driver: started dumper2 pid 9243
driver: started dumper3 pid 9244
dumper: dgram_bind: socket bound to 0.0.0.0.844
dumper: pid 9244 executable dumper3 version 2.4.4p3, using port 844
dumper: dgram_bind: socket bound to 0.0.0.0.843
dumper: pid 9243 executable dumper2 version 2.4.4p3, using port 843
dumper: dgram_bind: socket bound to 0.0.0.0.841
dumper: pid 9241 executable dumper0 version 2.4.4p3, using port 841
dumper: dgram_bind: socket bound to 0.0.0.0.842
dumper: pid 9242 executable dumper1 version 2.4.4p3, using port 842
planner: time 0.139: startup took 0.139 secs

SETTING UP FOR ESTIMATES...
planner: time 0.139: setting up estimates for allserver:/bin
taper: page size is 4096
taper: buffer size is 32768
taper: buffer[00] at 0x40224000
taper: buffer[01] at 0x4022c000
taper: buffer[02] at 0x40234000
taper: buffer[03] at 0x4023c000
taper: buffer[04] at 0x40244000
taper: buffer[05] at 0x4024c000
taper: buffer[06] at 0x40254000
taper: buffer[07] at 0x4025c000
taper: buffer[08] at 0x40264000
taper: buffer[09] at 0x4026c000
taper: buffer[10] at 0x40274000
taper: buffer[11] at 0x4027c000
taper: buffer[12] at 0x40284000
taper: buffer[13] at 0x4028c000
taper: buffer[14] at 0x40294000
taper: buffer[15] at 0x4029c000
taper: buffer[16] at 0x402a4000
taper: buffer[17] at 0x402ac000
taper: buffer[18] at 0x402b4000
taper: buffer[19] at 0x402bc000
taper: buffer structures at 0x402c4000 for 240 bytes
taper: read label `X-01-Manual' date `X'
taper: wrote label `X-01-Manual' date `20050603'
allserver:/bin overdue 12938 days for level 0
setup_estimate: allserver:/bin: command 0, options:
    last_level -1 next_level0 -12938 level_days 0
    getting estimates 0 (0) -1 (-1) -1 (-1)
planner: time 0.208: setting up estimates took 0.068 secs

GETTING ESTIMATES...
planner: time 1.318: got result for host allserver disk /bin: 0 -> 2890K, -1 -> -1K, -1 -> -1K
planner: time 1.318: getting estimates took 1.109 secs
FAILED QUEUE: empty
DONE QUEUE:
  0: allserver  /bin

ANALYZING ESTIMATES...
pondering allserver:/bin... next_level0 -12938 last_level -1 (due for level 0) (new disk, can't switch to degraded mode)
  curr level 0 size 1445 total size 4982 total_lev0 1445 balanced-lev0size 1445
INITIAL SCHEDULE (size 4982):
  allserver /bin pri 12940 lev 0 size 1445

DELAYING DUMPS IF NEEDED, total_size 4982, tape length 20029440 mark 1147
  delay: Total size now 4982.

PROMOTING DUMPS IF NEEDED, total_lev0 1445, balanced_size 1445...
planner: time 1.318: analysis took 0.000 secs

GENERATING SCHEDULE:
--------
ENDFLUSH
DUMP allserver fffffeff9ffe0f /bin 20050603 12940 0 1970:1:1:0:0:0 1445 48
--------
reserving 0 out of 0 for degraded-mode dumps
driver: flush size 0
driver: start time 1.312 inparallel 4 bandwidth 600 diskspace 0 dir OBSOLETE datestamp 20050603 driver: drain-ends tapeq FIRST big-dumpers ttt
driver: result time 1.312 from taper: TAPER-OK
driver: dumping allserver:/bin directly to tape
driver: send-cmd time 1.312 to taper: PORT-WRITE 00-00001 allserver fffffeff9ffe0f /bin 0 20050603
taper: try_socksize: receive buffer size is 65536
taper: stream_server: waiting for connection: 0.0.0.0.50035
driver: result time 1.313 from taper: PORT 50035
driver: send-cmd time 1.313 to dumper0: PORT-DUMP 01-00002 50035 allserver fffffeff9ffe0f /bin NODEVICE 0 1970:1:1:0:0:0 GNUTAR |;bsd-auth;compress-best;index;
dumper: stream_client: connected to 127.0.0.1.50035
dumper: stream_client: our side is 0.0.0.0.50036
dumper: try_socksize: send buffer size is 65536
taper: stream_accept: connection from 127.0.0.1.50036
taper: try_socksize: receive buffer size is 32768
driver: state time 1.326 free kps: 570 space: 0 taper: writing idle-dumpers: 3 qlen tapeq: 0 runq: 0 roomq: 0 wakeup: 86400 driver-idle: not-idle
driver: interface-state time 1.326 if : free 570
driver: hdisk-state time 1.326
dumper: stream_client: connected to 192.169.22.100.50050
dumper: stream_client: our side is 0.0.0.0.50037
dumper: stream_client: connected to 192.169.22.100.50051
dumper: stream_client: our side is 0.0.0.0.50038
dumper: stream_client: connected to 192.169.22.100.50052
dumper: stream_client: our side is 0.0.0.0.50039
driver: result time 13.801 from dumper0: DONE 01-00002 2890 1281 12 [sec 12.441 kb 1281 kps 103.0 orig-kb 2890]
taper: reader-side: got label X-01-Manual filenum 1
driver: result time 13.812 from taper: DONE 00-00001 X-01-Manual 1 [sec 12.487 kb 1282 kps 102.7 {wr: writers 42 rdwait 0.015 wrwait 0.306 filemark 12.161}]
driver: state time 13.813 free kps: 600 space: 0 taper: idle idle-dumpers: 4 qlen tapeq: 0 runq: 0 roomq: 0 wakeup: 86400 driver-idle: not-idle
driver: interface-state time 13.813 if : free 600
driver: hdisk-state time 13.813
driver: QUITTING time 13.813 telling children to quit
driver: send-cmd time 13.813 to dumper0: QUIT
driver: send-cmd time 13.813 to dumper1: QUIT
driver: send-cmd time 13.813 to dumper2: QUIT
driver: send-cmd time 13.813 to dumper3: QUIT
driver: send-cmd time 13.813 to taper: QUIT
taper: DONE [idle wait: 0.968 secs]
taper: writing end marker. [X-01-Manual OK kb 1344 fm 1]
driver: FINISHED time 16.462
amdump: end at Fri Jun  3 14:00:29 CEST 2005

Questo è l'altro file di log:

cat /var/log/amanda/DailySet1/log.20050603.0

START driver date 20050603
DISK planner allserver /bin
START planner date 20050603
WARNING planner tapecycle (1) <= runspercycle (1)
INFO planner Adding new disk allserver:/bin.
START taper datestamp 20050603 label X-01-Manual tape 0
FINISH planner date 20050603
STATS driver startup time 1.312
SUCCESS dumper allserver /bin 20050603 0 [sec 12.441 kb 1281 kps 103.0 orig-kb 2890]
SUCCESS taper allserver /bin 20050603 0 [sec 12.487 kb 1282 kps 102.7 {wr: writers 42 rdwait 0.015 wrwait 0.306 filemark 12.161}]
INFO taper tape X-01-Manual kb 1344 fm 1 [OK]
FINISH driver date 20050603 time 16.507

Verifica del Backup

amverify DailySet1
No tape changer...
Tape device is /dev/nst0...
System restore program not found: /sbin/restore
System restore program not found: /sbin/xfsrestore
Verify summary to all-alert@rvmgroup.it
Defects file is /tmp/amanda/amverify.11888/defects
amverify DailySet1
Fri Jun  3 14:08:41 CEST 2005

Using device /dev/nst0
Waiting for device to go ready...
Rewinding...
Processing label...
Volume X-01-Manual, Date 20050603
Rewinding...
Checked allserver._bin.20050603.0
End-of-Tape detected.
Rewinding...


Modifica per configurazione definitiva

Impostare / nel disklist:

cat > /etc/amanda/DailySet1/disklist <<'EOFile'
# File format is:
#       hostname diskdev dumptype
# where the dumptypes are defined by you in amanda.conf.

localhost / always-full
#nomeserver disco dumptype
EOFile

Testare la configurazione:

su backup -c '/usr/sbin/amcheck DailySet1'

Amanda Tape Server Host Check
-----------------------------
NOTE: skipping tape-writable test
Tape X-01-Manual label ok
NOTE: info dir /var/lib/amanda/DailySet1/curinfo/allserver/_: does not exist
NOTE: index dir /var/lib/amanda/DailySet1/index/allserver/_: does not exist
Server check took 0.253 seconds

Amanda Backup Client Hosts Check
--------------------------------
Client check: 1 host checked in 0.297 seconds, 0 problems found

(brought to you by Amanda 2.4.4p3)

Impostazione per l'esecuzione Schedulata

La schedulazione avviene modifcando il crontab per l'utente backup.

Modifcare il file /etc/amanda/crontab.amanda

cat >/etc/amanda/crontab.amanda <<'EOFile'
# This is an example for a crontab entry for automated backup with amanda
# With these cron lines, Amanda will check that the correct tape is in
# the drive every weekday afternoon at 4pm (if it isn't, all the
# operators will get mail).  At 12:45am that night the dumps will be run.

0 17 * * 1-5    /usr/sbin/amcheck -m DailySet1
# Testa per vedere se è inserito il nastro. In caso di errore 
# viene mandata una mail all'indirizo specificato in configurazione

5 22 * * 1-5    /usr/sbin/amdump DailySet1
# Lancia il backup DailySet1

0 07 * * 2-6    /usr/sbin/ammt -f /dev/st0 rewoffl
# Espelle il nastro
EOFile

Attivare il crontab:

crontab -u backup /etc/amanda/crontab.amanda

Verificare l'attivazione:

su backup -c 'crontab -l'
# This is an example for a crontab entry for automated backup with amanda
# With these cron lines, Amanda will check that the correct tape is in
# the drive every weekday afternoon at 4pm (if it isn't, all the
# operators will get mail).  At 12:45am that night the dumps will be run.

0 17 * * 1-5    /usr/sbin/amcheck -m DailySet1
# Testa per vedere se è inserito il nastro. In caso di errore
# viene mandata una mail all'indirizo specificato in configurazione

5 22 * * 1-5    /usr/sbin/amdump DailySet1
# Lancia il backup DailySet1

0 07 * * 2-6    /usr/sbin/ammt -f /dev/st0 rewoffl
# Espelle il nastro

Effettuare quanto prima un aprovaq di restore.