Introduzione
Amanda è un tool di backup che permette di effettuare il backup di più server linux e windows da una sola macchina con la possibilità di ricevere rapporti via e-mail e poter usare come supporto anche un masterizzatore.
E' un software molto utile ma altrettanto rigido, infatti, prima esegue il backup su cache (bumpsize), e successivamente lo copia nel tape.
Amanda numera inoltre le cassette dando un'etichetta come da file di configurazione, per tanto andranno inserite una alla volta ed "etichettate" con l'apposito comando.
Nel caso mancasse la cassetta nel tape o fosse quella sbagliata, verrà inviata una mail, e il backup rimarrà nella cache (che aumenterà se non vuotata prima del successivo backup mediante l'apposito comando amflush) per tanto insisto nel ricordare di UTILIZZARE AMANDA SOLO SE CONSAPEVOLI, ma in tal caso è un tool eccellente.
Esempio di caratteristiche di amanda; nel caso vogliate recuperare un determinato file sarà lei a segnalarvi quale cassetta inserire e a segnalarvi la possibilità di versioni più o meno recenti in altre cassette.
esempio: server_amanda 192.168.1.254 (nome: serverbck01 )
- client_amanda 192.168.1.100 (nome: worktation01 )
Installazione
Installiamo tutto ciò che ci servirà sul server (cioè la macchina con installata l'unita nastro).
Da shell:
sudo apt-get install -y amanda-client amanda-server xinetd
Nel caso in cui vogliate backuppare più workstation consiglio l'installazione di samba poiché permetterà di includere nei client di amanda anche macchine windows.
sudo apt-get install -y samba smbfs smbclient
Installiamo tutto ciò che ci servirà sul Client
Da shell:
sudo apt-get install -y amanda-client
Come primo passo configureremo xinetd in entrambi i pc: Vorrei far notare che con inetd ci sono ancora molti problemi per amanda in ubuntu (per debian è l'opposto).
vi /etc/xinetd.d/amanda
e aggiungete le righe seguenti in fondo al file:
service amanda { socket_type = dgram protocol = udp wait = yes user = $USER group = $GROUP groups = yes server = $AMANDAD_PATH/amandad }
creiamo la cartella del superserver
mkdir -p /etc/amanda/supervise/amanda
creiamo uno script /etc/amanda/supervise/amanda/run:
touch /etc/amanda/supervise/amanda/run
e vi scriviamo dentro
exec /usr/local/bin/setuidgid amanda \ /usr/bin/netcat -l -u -p 10080 -q 0 \ -e /usr/local/libexec/amandad >/dev/null 2>/dev/null
lo rendiamo eseguibile
chmod 755 /etc/amanda/supervise/amanda/run
ora creiamo un link simbolico nei servizi
cd /service ln -s /etc/amanda/supervise/amanda .
Nota: è importante utilizzare il tab, non gli spazi nella configurazione del ined.conf
Oppure seguite la guida a inetd e xinetd originale [http://www.amanda.org/docs/install.html#id2528595]
Ora creiamo le directory e i file necessarie e settiamo i permessi:
mkdir -p /usr/local/var/amanda/gnutar-lists mkdir /tmp/amanda touch /etc/amandates
Ora andiamo a creare ed impostare i file di configurazione che userà il programma
sudo vi /etc/amandahosts
che dovrà avere una struttura come la seguente:
localhost backup localhost root localhost.localdomain backup localhost.localdomain root serverbck01 backup serverbck01 root worktation01 backup worktation01 root
successivamente:
sudo vi /etc/amanda/Daily``Set1/exclude.gtar
Questo era il file delle cartelle da escludere, potremmo scriverci alcune righe come queste per evitare il backup di file temporanei, mp3, avi e una cartella precisa:
tmp lost+found /var/spool/amanda/ *.mp3 *.avi /home/file_da_non_copiare
ora:
sudo touch /etc/amanda/DailySet1/tapelist.amlabel sudo touch /etc/amanda/DailySet1/tapelist.yesterday sudo touch /etc/amanda/DailySet1/tapelist sudo touch /var/lib/amanda/DailySet1/curinfo sudo touch /var/log/amanda/DailySet1/log sudo touch /var/lib/amanda/DailySet1/index sudo mkdir -p /var/spool/amanda/tmp
Ora:
sudo vi /etc/amanda/DailySet1/disklist
Disklist è l'elenco delle cartelle da copiare, noi potremmo scriverci:
serverbck01 /etc comp-user-tar serverbck01 /etc comp-user-tar worktation01 /etc comp-user-tar worktation01 /home comp-user-tar worktation01 /home/utente/filedacopiare
Nel caso ci fosse un client windows (workstation02) potremmo montare la cartella condivisa come samba file system in una cartella apposita
sudo mkdir /home/bck_smb smbmount //workstation02/SharedDocs /home/bck_smb -o username=utente,password=secret,rw
oppure al posto di smbmount, sempre dopo aver creato la cartella /home/bck_smb modificate /etc/fstab aggiungendo la seguente riga:
//workstation02/SharedDocs /home/bck_smb smbfs username=utente,password=secret 0 0
ed aggiungete a /etc/amanda/DailySet1/disklist
serverbck01 /home/bck_smb comp-user-tar
Ora la vera configurazione del tape, della compressione, ecc... :
sudo mv /etc/amanda/DailySet1/amanda.conf /etc/amanda/DailySet1/amanda.conf.original sudo vi /etc/amanda/DailySet1/amanda.conf
Questo è il file di configurazione del set di backup, rifacendolo da zero, scriveteci:
Vorrei far notare che in questo file dovrete adattarlo inserendo una sezione (se non presente) per le dimensioni del vostro tape e settare i dump, l'email e i dati necessari, studiate le righe commentate per non sbagliare, ho comunque cercato di inserire già molti dei tape presenti in commercio.
PS: spesso le dimensioni e i dati specifici per il vostro tape le potrete trovare direttamente in google evitando il controllo lentissimo di amanda.
# # amanda.conf - sample Amanda configuration file. # # If your configuration is called, say, "DailySet1", then this file # normally goes in /etc/amanda/DailySet1/amanda.conf. # # for explanation of the parameters refer to amanda(8) and # /usr/doc/amanda/WHATS.NEW.gz org "Società" # your organization name for reports mailto "root@domain.com" # space separated list of operators at your site dumpuser "backup" # the user to run dumps under # inparallel 4 # maximum dumpers that will run in parallel netusage 15000 # maximum net bandwidth for Amanda, in KB per sec maxdumps 2 # a filesystem is due for a full backup once every <dumpcycle> days dumpcycle 5 days # the number of days in the normal dump cycle tapecycle 5 tapes # the number of tapes in rotation bumpsize 500 MB # minimum savings (threshold) to bump level 1 -> 2 bumpdays 1 # minimum days at each level bumpmult 2 # threshold = bumpsize * (level-1)**bumpmult #runtapes 9 # explained in WHATS.NEW #tpchanger "no-changer" # the tape-changer glue script, see TAPE.CHANGERS tapedev "/dev/nst0" # Linux @ tuck, important: norewinding # tapedev "/dev/nrst8" # or use the (no-rewind!) tape device directly tapetype SLR7 # what kind of tape it is (see tapetypes below) labelstr "Backup[0-9]" # label constraint regex: all tapes must match diskdir "/var/spool/amanda/tmp" # where the holding disk is disksize 5000 MB # how much space can we use on it #diskdir "/dumps/amanda/work" # additionaly holding disks can be specified #diskdir "/mnt/disk4" #disksize 1000 MB # they are used round-robin # Amanda needs a few MB of diskspace for the log and debug files, # as well as a database. This stuff can grow large, so the conf directory # isn't usually appropriate. infofile "/var/lib/amanda/DailySet1/curinfo" # database filename logfile "/var/log/amanda/DailySet1/log" # log filename # where the index files live indexdir "/var/lib/amanda/DailySet1/index" # tapetypes # # Define the type of tape you use here, and use it in "tapetype" above. # Some typical types of tapes are included here. The tapetype tells amanda # how many MB will fit on the tape, how big the filemarks are, and how # fast the tape device is. # # For completeness Amanda should calculate the inter-record gaps too, but it # doesn't. For EXABYTE and DAT tapes this is ok. Anyone using 9 tracks for # amanda and need IRG calculations? Drop me a note if so. #define tapetype HP { # comment "just produced by tapetype prog (hardware compression off)" # length 19442 mbytes # filemark 76 kbytes # speed 1760 kps #} define tapetype SLR7 { comment "Produced by tapetype program-TANDBERG SLR7" length 18549 mbytes filemark 1034 kbytes speed 1470 kps } define tapetype SLR75 { comment "Produced by tapetype program-TANDBERG SLR75" length 39005 mbytes filemark 256 kbytes speed 1721 kps } define tapetype QIC-60 { comment "Archive Viper" length 60 mbytes filemark 100 kbytes # don't know a better value speed 100 kbytes # dito } define tapetype DEC-DLT2000 { comment "DEC Differential Digital Linear Tape 2000" length 15000 mbytes filemark 8 kbytes speed 1250 kbytes } # goluboff@butch.Colorado.EDU # in amanda-users (Thu Dec 26 01:55:38 MEZ 1996) define tapetype DLT { comment "DLT tape drives" length 20000 mbytes # 20 Gig tapes filemark 2000 kbytes # I don't know what this means speed 1536 kbytes # 1.5 Mb/s } define tapetype SURESTORE-1200E { comment "HP AutoLoader" length 3900 mbytes filemark 100 kbytes speed 500 kbytes } define tapetype EXB-8500 { comment "Exabyte EXB-8500 drive on decent machine" length 4200 mbytes filemark 48 kbytes speed 474 kbytes } define tapetype EXB-8200 { comment "Exabyte EXB-8200 drive on decent machine" length 2200 mbytes filemark 2130 kbytes speed 240 kbytes } define tapetype HP-DAT { comment "DAT tape drives" # data provided by Rob Browning <rlb@cs.utexas.edu> length 1930 mbytes filemark 111 kbytes speed 468 kbytes } define tapetype DAT { comment "DAT tape drives" length 1000 mbytes # these numbers are not accurate filemark 100 kbytes # but you get the idea speed 100 kbytes } define tapetype MIMSY-MEGATAPE { comment "Megatape (Exabyte based) drive through Emulex on Vax 8600" length 2200 mbytes filemark 2130 kbytes speed 170 kbytes # limited by the Emulex bus interface, ugh } define tapetype DLT-4000 { comment "DLT-4000" length 20000 mbytes filemark 8 kbytes speed 1500 kbytes } define tapetype DLT-4000-compress { comment "DLT-4000 with compression" length 40000 mbytes filemark 8 kbytes speed 1500 kbytes } define tapetype DLT-8000 { comment "DLT-8000" length 40000 mbytes filemark 8 kbytes speed 4263 kbytes } define tapetype DLT-8000-compress { comment "DLT-8000 with compression" length 70000 mbytes filemark 8 kbytes speed 4263 kbytes } # dumptypes # # These are referred to by the disklist file. The dumptype specifies # certain "options" for dumping including: # index - keep an index of the files backed up # compress-fast - (default) compress on the client using fast algorithm # compress-best - compress using the best (and slowww) algorithm # no-compress - don't compress the dump output # srvcompress - Compress dumps on the tape host instead of client # machines. This may be useful when a fast tape host # is backing up slow clients. # record - (default) record the dump in /etc/dumpdates # no-record - don't record the dump, for testing # no-hold - don't go to the holding disk, good for dumping # the holding disk partition itself. # skip-full - Skip the disk when a level 0 is due, to allow # full backups outside Amanda, eg when the machine # is in single-user mode. # skip-incr - Skip the disk when the level 0 is NOT due. This # is used in archive configurations, where only full # dumps are done and the tapes saved. # no-full - Do a level 1 every night. This can be used, for # example, for small root filesystems that only change # slightly relative to a site-wide prototype. Amanda # then backs up just the changes. # # Also, the dumptype specifies the priority level, where "low", "medium" and # "high" are the allowed levels. These are only really used when Amanda has # no tape to write to because of some error. In that "degraded mode", as # many incrementals as will fit on the holding disk are done, higher priority # first, to insure the important disks are dumped first. define dumptype always-full { comment "Full dump of this filesystem always" options no-compress priority high dumpcycle 0 maxcycle 0 } define dumptype comp-user-tar { program "GNUTAR" comment "partitions dumped with tar" options compress-best, index, exclude-list "/etc/amanda/exclude.gtar" priority medium } define dumptype hq-comp-user-tar { program "GNUTAR" comment "partitions dumped with tar" options compress-best, index, exclude-list "/etc/amanda/DailySet1/exclude.gtar" priority medium dumpcycle 0 maxcycle 0 } define dumptype hq-incr-user-tar { program "GNUTAR" comment "partitions dumped with tar" options compress-best, index, exclude-list "/etc/amanda/DailySet1/exclude.gtar" priority medium dumpcycle 3 maxcycle 4 } define dumptype comp-root-tar { program "GNUTAR" comment "Root partitions with compression" options compress-fast, index, exclude-list "/etc/amanda/exclude.gtar" priority low } define dumptype user-tar { program "GNUTAR" comment "partitions dumped with tar" options no-compress, index, exclude-list "/etc/amanda/exclude.gtar" priority medium } define dumptype high-tar { program "GNUTAR" comment "partitions dumped with tar" options no-compress, index, exclude-list "/etc/amanda/exclude.gtar" priority high } define dumptype root-tar { program "GNUTAR" comment "Root partitions dumped with tar" options no-compress, index, exclude-list "/etc/amanda/exclude.gtar" priority low } define dumptype comp-user { comment "Non-root partitions on reasonably fast machines" options compress-fast priority medium } define dumptype nocomp-user { comment "Non-root partitions on slow machines" options no-compress priority medium } define dumptype holding-disk { comment "The master-host holding disk itself" options no-hold priority medium } define dumptype comp-root { comment "Root partitions with compression" options compress-fast priority low } define dumptype nocomp-root { comment "Root partitions without compression" options no-compress priority low } define dumptype comp-high { comment "very important partitions on fast machines" options compress-best priority high } define dumptype nocomp-high { comment "very important partitions on slow machines" options no-compress priority high } define dumptype nocomp-test { comment "test dump without compression, no /etc/dumpdates recording" options no-compress, no-record priority medium } define dumptype comp-test { comment "test dump with compression, no /etc/dumpdates recording" options compress-fast, no-record priority medium }
Creiamo i servizi necessari ad amanda per funzionare in background:
vi /etc/services
aggiungete, se non presenti, le seguenti righe:
amanda 10080/udp amandaidx 10082/tcp amidxtape 10083/tcp
Bene abbiamo quasi finito la preconfigurazione, dobbiamo ora aggiungere in /etc/crontab le seguenti righe in modo da schedulare i comandi, cioè facciamo controllare alle 4 del pomeriggio se tutto è pronto (in caso di errore il -m manderà una email) ed impostiamo il backup alle 00:45
0 16 * * 1-5 /usr/sbin/amcheck -m DailySet1 45 0 * * 1-5 /usr/sbin/amdump DailySet1
ove indicheremo 1-5 per effettuare il backup da lunedì a venerdì (la domenica viene indicata con 0 oppure con 7).
effettuiamo subito una verifica ed eventualmente creiamo cartelle o settiamo permessi come verrà richiesto:
/usr/sbin/amcheck DailySet1
Ora Amanda è installato nel sistema.
Configurazione
Dobbiamo sempre ricordare che tutti i comandi di amanda adranno eseguiti dall'utente creato automaticamente BACKUP quindi per procedere con i comandi daremo:
su backup
Ora utilizzeremo i seguenti comandi:
amtapetype -e 100g -f <device> ------Verifica le dimensioni del tape calcolando il temposecondo la dimensione stimata di 100 Gb (non necessario il -e 100g) amlabel -f DailySet1 ------si etichettano le cassette (ripetere il comando per ogni cassetta) amcheck DailySet1 ------prova di controllo cassetta corretta amdump DailySet1 ------effettua il backup amverify DailySet1 ------verifica i dati scritti amflush ------vuota la cache rimasta piena in caso di errore su una cassetta qualsiasi anche non etichettata.
D'altro canto se volessimo recuperare i dati avremmo 2 possibilità;
utilizzare una shell interattiva "amrecover"
amrecover -s ipDELserver -C DailySet1 sethost nomehost setdisk /path/pathdarecuperare add nomefiledarecuperare lcd /recovery extract
oppure dare un comando di shel semi interattiva:
amrestore -p /dev/nst0 localhost Backup5 | restore -ivbf 2 -
Ed infine anche dare il comando seguente che è quello più semplice:
amrestore /dev/nst0 localhost
Quest'ultimo effettuerà un restore completo della macchina, per uscire basta premere Ctrl+D.
Ora amanda ora dovrebbe funzionare.
Per eventuali Bug segnalatemeli a luca.piccinini@email.it oppure consultate la documentazione disponibile nel sito di amanda.
CategoryDaRevisionare CategoryServer CategoryAmministrazione