設定Amanda

(Redirected from Setting up Amanda)
Jump to: navigation, search

◄設定


這是個簡單的設定Amanda 備份在本機端的例子

這是基於這個很棒的解決方案文章而成的 "Using Amanda to Backup Your Linux Server": [1]

我在 IBM xSeries 225 上安裝openSUSE 10.2 並搭配 20/40 GB SCSI 磁帶裝置/dev/nst0.


以root 身份執行Yast 安裝Amanda


第一次安裝好了之後,你需要從xinet.d 服務中去打開amanda,編輯 /etc/xinetd.d/amanda 這個檔案,找到一行disable = yes 改成 disable = no 然後重新啟動xinetd。


小記: 在openSUSE 10.3 的設定方面還需要改變xinetd.d 服務設定才能正常工作。可以看這一頁的最後有我的做法。


開始的第一件事,要先確定amanda 可以正常的偵測得到磁帶裝置。把磁帶放入到磁帶機(所有磁帶資料將會被清除掉) 並且執行下列(-e 是我的磁帶容量大小):


   amtapetype -o -f /dev/nst0 -e 20G

這將會花費一些時間並進行一些動作,就像下列所述:

   define tapetype unknown-tapetype {
       comment "just produced by tapetype prog (hardware compression on)"
       length 16385 mbytes
       filemark 32 kbytes
       speed 2152 kps
   }

將這個覆製成文字檔並好好保存起來。

當我們寫好我們的設定檔,我們還需要設定有多少磁帶要被Amanda 所使用。這裡有一個現成的script: [2] 你可以決定它要處理多少數量。 下載到根目錄執行它,當我們寫好設定檔,他會註記使用多少數量。

就像我使用了5個磁帶給星期一到星期五的備份script:

   dumpcycle 1 week
   runspercycle 5
   runtapes 1
   tapecycle 6 tapes

是的,他說有6個磁帶,允許至少一個以上的磁帶能使用是比較好的,可以看看amanda 的文件。

現在我們設定目錄來備份,我使用fullback:

   mkdir /etc/amanda/fullback
   chown amanda.disk /etc/amanda/fullback

在fullback 目錄我們建立這些設定檔: amanda.conf,disklist 以及 fullback.exclude

這裡我們覆製我的 amanda.conf 這裡包含從amtapetype 與下列這個磁帶數量script 的資訊:

   org "FSC World" # Title of report
   mailto "root" # recipients of report, space separated
   dumpuser "amanda" # the user to run dumps under
   inparallel 4 # maximum dumpers that will run in parallel
   netusage 600 # maximum net bandwidth for Amanda, in KB per sec
   
   dumpcycle 1 week
   runspercycle 5
   runtapes 1
   tapecycle 6 tapes
   
   bumpsize 20 MB
   bumpdays 1
   bumpmult 4
   
   tapedev "/dev/nst0"
   
   tapetype SEGATEDAT-40
   labelstr "^FULLBACK-[0-9][0-9]*$"
   
   holdingdisk hd1 {
   	comment "Temporary holding space"
   	directory "/var/tmp/amanda"
   	use 2000 MB
   }
   
   infofile "/var/lib/amanda/fullback/curinfo"
   logdir "/var/log/amanda/fullback"
   
   indexdir "/var/lib/amanda/fullback/index"
   
   define tapetype SEGATEDAT-40 {
       comment "SEGATE 40GB DAT (hardware compression on)"
       length 16385 mbytes
       filemark 32 kbytes
       speed 2152 kps
   }
   
   define dumptype root-tar {
   program "GNUTAR"
   comment "root partition dump with tar"
   index yes
   dumpcycle 0
   exclude list "/etc/amanda/fullback/fullback.exclude"
   priority high
   }
   

小記:設定 dumpcycle 0 參數到define dumptype rot-tar { 設定檔尾端的範圍之內,應該能讓我們每天都有完整備份。如果你想要用遞增的方式。


我們的fullback.exclude 就覆製這裡的:

   /proc
   /tmp
   

再來是我們最後的disklist。這是我們要告訴amanda 要備份什麼地方。我要備份我的根目錄 / :

   localhost / root-tar

現在我們設定好一些檔案、目錄以及一些權限:

   mkdir /var/tmp/amanda
   mkdir /var/lib/amanda/fullback
   mkdir /var/lib/amanda/fullback/index
   mkdir /var/log/amanda
   mkdir /var/log/amanda/fullback
   
   touch /etc/amanda/fullback/tapelist
   touch /var/lib/amanda/amandates
   
   chown amanda.disk /var/tmp/amanda
   chown amanda.disk /etc/amanda/fullback/*
   chown amanda.disk /var/lib/amanda/amandates
   chown -R amanda.disk /var/lib/amanda/fullback
   chown amanda.disk /var/log/amanda/fullback
   
   chmod 770 /var/tmp/amanda
   chmod 770 /etc/amanda/fullback
   chmod 700 /etc/amanda/fullback/*
   chmod -R 770 /var/lib/amanda/fullback
   chmod 770 /var/log/amanda/fullback
   

接下來,你應該執行amcheck 檢查看看

   su amanda
   amcheck fullback

解決有問題的錯誤! - 在這一頁的最後會有兩個提示幫助你。


你要開始為每個磁帶設定label,你需要分別放進每一片磁帶並每次執行amlabel 來建立。這裡還會順便執行amcheck 檢查你的設定並告訴你每個一錯誤。

   su amanda
   amlabel fullback FULLBACK-01

接著下一片

   amlabel fullback FULLBACK-02


當你執行好label 的動作之後,你現在就可以開始進行你的備份:

   su amanda
   amdump fullback

每次完成備份動作之後,你的root 信箱就會得到執行結果的報告。 Once it's finished you should get an email in the root mailbox account with the results.

如果備份動作成功,你可以建立script 放到cron 去週期性的運作:

在你的crontab:

   01 00 * * 1-5 /root/backup.sh

還有你的script /root/backup.sh

   # Change to amanda user and run amanda dump program
   su amanda -c "/usr/sbin/amdump fullback
   
   # Eject the tape
   sg_start /dev/nst0 –eject


Errors / Trouble shooting

當你執行amcheck 檢查之後,你可能得到一些錯誤:

1

ERROR localhost NAK: user amanda from localhost is not allowed to execute the service noop: /var/lib/amanda/.amandahosts: incorrect permissions; file must be accessible only by its owner

確定一下你的 /var/lib/amanda/.amandahosts 檔案有存在,並且有寫上 "localhost amanda" 然後設定一下使用權限:

   chown amanda:disk /var/lib/amanda/.amandahosts
   chmod 600 /var/lib/amanda/.amandahosts


2

WARNING: localhost: selfcheck request failed: Connection refused

修改你的xinet.d 服務像下列一樣:

Service settings for xinet.d on OpenSUSE 10.3

   service amanda
   {
   	disable = no
   	socket_type = stream
   	protocol = tcp
   	wait = no
   	user = amanda
   	group = disk
   	groups = yes
   	server = /usr/lib/amanda/amandad
   	server_args = -auth=bsdtcp amdump amindexd amidxtaped
   }

然後,在你amanda.conf 之中,找到你定義的備份磁帶section 範圍內新增這個參數:

   auth "bsdtcp"