Solaris10.0 文件系統(tǒng)備份和恢復
發(fā)布日期:2021-12-14 15:47 | 文章來源:站長之家
一、磁帶和磁帶機:
常見的磁帶介質如下表所示:
1.磁帶驅動器:
磁帶的邏輯設備名格式為:/dev/rmt/#hn
#代表磁帶邏輯編號,總是以0開始,標識磁盤驅動器的第一個實例。
h代表磁帶密度,可分為:l(低)、m(中)、h(高)、c(壓縮)及u(高壓縮的)。
n代表no-rewind,即操作完成后,不能倒帶。
磁帶驅動器支持硬件壓縮,但壓縮比不如軟件壓縮,不過壓縮速度比軟件壓縮快。默認的磁帶設備名字存放在/kernel/drv/st.conf文件中。
2、磁帶驅動器控制命令:mt
并非所有的磁帶驅動器都支持mt命令的所有選項,mt命令的格式如下:mt -f tape-device-name command count
命令示例:
mt status:顯示磁帶驅動器的狀態(tài)信息。
mt rewind:倒帶
mt offline:倒帶并離線,如果硬件支持就卸載。
mt fsf count:前進到指定的記錄點。
以下命令把磁帶定位到第三個記錄的開始點:
# mt -f /dev/rmt/0n fsf 2
二、備份軟件:
在solaris中用的最多的備份軟件是Veritas Netbackup(簡稱NBU),這里只談solaris自帶的備份工具;
Ufsdump:用于備份文件系統(tǒng);
Ufsrestore:用于從備份中恢復數(shù)據(jù);
Fssnap:用于創(chuàng)建文件系統(tǒng)的在線快照,然后通過快照實現(xiàn)在線文件系統(tǒng)的備份。
三、執(zhí)行備份作業(yè):
備份有三種:全備、增量備份和差異備份。
1. 增量備份:
Solaris采用數(shù)字0~9來區(qū)分不同的備份類型,0代表全備,1~9表示備份比其數(shù)字更低的最近一次備份以來更新的所有數(shù)據(jù)。例如增量備份策略情況如下所示:
周六 周一 周二 周三 周四 周五
0 3 4 5 6 2
0級備份指的是月備份策略。
每月一次全備,周一至周四執(zhí)行3~6級備份,周五執(zhí)行2級備份。
2./etc/dumpdates
這是備份作業(yè)的歷史記錄文件,備份作業(yè)完成一次都會在這個文件中增加一條記錄,如果本次備份的級別和上一次備份的級別一樣,則會刷新上次的備份記錄。
# cat /etc/dumpdates
/dev/rdsk/c0t2d0s6 0 Fri Nov 5 19:12:27 2007 ---0級備份
/dev/rdsk/c0t2d0s0 0 Fri Nov 5 20:44:02 2007---0級備份
/dev/rdsk/c0t0d0s7 0 Tue Nov 9 09:58:26 2007---0級備份
/dev/rdsk/c0t0d0s7 1 Tue Nov 9 16:25:28 2007---0級備份
Ufsdump每次執(zhí)行前都會檢查這個文件,查找比本次備份級別低的最近一次備份作業(yè)記錄決定從哪個日期開始備份文件,如果備份作業(yè)失敗,則不會更新/etc/dumpdates文件。
3./usr/sbin/ufsdump
該命令的語法如下:
ufsdump option(s) argument(s) filesystem_name
ufsdump的選項如下表所示:
4.備份本地的磁帶:
(1),通告所有用戶,系統(tǒng)將進行備份,切換到單用戶模式:
# /usr/sbin/shutdown -y -g300 'System is being shutdown for backup'
(2),檢查文件系統(tǒng)的一致性:
fsck /export/home
(3),備份到磁帶:
# ufsdump 0uf /dev/rmt/0 /export/home
5.備份到遠程的磁帶:
(1),遠程系統(tǒng)必須在/.rhosts文件中包含本機的名字:
host2# vi /.rhosts
host1
(2).在本機執(zhí)行以下命令:
host1# ufsdump 0uf host2:/dev/rmt/0 /export/home
6.備份實例:
(1).倒帶:
#mt rewind
(2).創(chuàng)建/export/home的備份:
#ufsdump 0S /export/home
#umount /export/home-若顯示系統(tǒng)busy,#umount -f /export/home強行卸載。
#ufsdump 0uf /dev/rmt/0 /export/home
#cat /etc/dumpdates-----全備完成,文件中增加一條0級記錄。
(3).添加文件和目錄到/export/home文件系統(tǒng):
#mount /dev/dsk/c0t0d0s7 /export/home
#cp -r /root/ /export/home
#umount /export/home
(4).進行增量備份:
#mt -f /dev/rmt/0 fsf 1 ---跳到下一個記錄點,進行第二次備份操作。
#ufsdump 1uf /dev/rmt/0 /export/home
(5)移走磁帶:
#mt offline
(6)查看備份記錄文件:
#cat /etc/dumpdates ----1級增備完成。
四、執(zhí)行恢復作業(yè):
這里使用的命令是ufsrestore,其格式和選項說明如下所示:
Ufsrestore option(s) argument(s) filesystem
選項說明:
當從一個備份磁帶恢復整個文件系統(tǒng)時,系統(tǒng)會創(chuàng)建一個restoresymtable文件,ufsrestore命令使用restoresymtable文件在增量恢復的時候進行關鍵點檢測或忽略信息,以及把磁帶上的被備份的文件系統(tǒng)的inode映射到磁盤上的新文件系統(tǒng)中的文件,恢復完成后可刪除restoresymtable文件。Ufsrestore默認總是把文件恢復到當前目錄下。
命令示例介紹:
(1)顯示磁帶中的內容:
# ufsrestore tf /dev/rmt/0
(2)只恢復兩個指定的文件:
# ufsrestore xf /dev/rmt/0 ./xx/xx.file1 ./xx/xx.file2
(3)把c1t0d0s0的文件轉儲到newroot目錄:
# ufsdump 0f - /dev/rdsk/c1t0d0s0|(cd /tmp/newroot;ufsrestore xf -)
(4)進入交互式恢復模式:
# ufsretore if /dev/rmt/0
1、恢復/opt文件系統(tǒng)(c0t0d0s5)
(1)創(chuàng)建新的文件系統(tǒng):
#newfs /dev/rdsk/c0t0d0s5 ---假設/opt文件系統(tǒng)處在/c0t0d0s5
(2)掛接到/opt目錄,并進入/opt目錄:
#mount /dev/dsk/c0t0d0s5 /opt
#cd /opt
(3)從備份磁帶恢復/opt文件系統(tǒng):
#ufsrestore rf /dev/rmt/0
(4)刪除restoresymtable文件:
#rm restoresymtable
(5)卸載文件系統(tǒng):
#cd /;umount /opt
(6)使用fsck校驗文件系統(tǒng)的完整性:
#fsck /dev/rdsk/c0t0d0s5
(7)執(zhí)行該文件系統(tǒng)的全備(因為恢復整個文件系統(tǒng)的時候inode number重新分配,所以要再次全備)
#ufsdump 0uf /dev/rmt/0 /dev/rdsk/c0t0d0s5 ---可直接對裸設備備份
注:當恢復整個文件系統(tǒng)時,總是從0級備份磁帶開始,然后逐級增加,恢復完后一定要再次全備,因為ufsrestore改變了文件的位置和inodes的分配。
2、恢復/usr文件系統(tǒng)(c0t0d0s6)
(1)如果/,/var,/usr文件系統(tǒng)受到破壞,就要進入單用戶模式:
Ok boot cdrom -s
(2)恢復步驟:
#newfs /dev/rdsk/c0t0d0s6 ---假設/usr文件系統(tǒng)處在/c0t0d0s6
#mount /dev/dsk/c0t0d0s6 /a
#cd /a
#ufsrestore rf /dev/rmt/0
#rm restoresymtable
#cd /;umount /a
#fsck /dev/rdsk/c0t0d0s6
#ufsdump 0uf /dev/rmt/0 /dev/rdsk/c0t0d0s6
(3)重啟系統(tǒng):
#init 6
3、恢復/文件系統(tǒng)(c0t0d0s0)
(1)進入單用戶模式:
Ok boot cdrom -s
(2)恢復步驟:
#newfs /dev/rdsk/c0t0d0s0
#mount /dev/dsk/c0t0d0s0 /a
#cd /a; ufsrestore rf /dev/rmt/0
# rm restoresymtable
#cd /usr/platform/`uname -m`/lib/fs/ufs
安裝新的啟動引導信息到跟分區(qū)的扇區(qū)1到扇區(qū)15,sparc和x86如下所示:
SPARC#installboot bootblk /dev/rdsk/c0t0d0s0
如果是x86版使用installgrub命令:
X86#installgrub /boot/grub/stage1 /boot/grub/stage2 /dev/rdsk/c0t1d0s0
# cd /;umount /a
#fsck /dev/rdsk/c0t0d0s0
# ufsdump 0uf /dev/rmt/0 /dev/rdsk/c0t0d0s0
(3)重啟系統(tǒng):
#init 6
4、交互式恢復:
(1)進入交互式恢復界面:
#cd /export/home/tmp
#ufsrestore ivh /dev/rmt/0
Verify volume and initialize maps
Media block size is 64
Dump date: Mon Oct 11 12:30:44 2004
Dumped from: the epoch
Level 0 dump of /export/home on sys43:/dev/dsk/c0t0d0s7
Label: none
Extract directories from tape
Initialize symbol table.
(2)顯示磁帶中目錄結構的內容:
ufsrestore > ls
.:
2 *./ 13 directory1 15 directory3 11 file2
2 *../ 14 directory2 10 file1 12 file3
ufsrestore > cd directory1
ufsrestore > ls
./directory1:
3904 ./ 2 *../ 3905 file1 3906 file2 3907 file3
(3)選擇想要恢復的文件,可看到文件前面*號表示被選擇:
ufsrestore > add file1 file2
Make node ./directory1
Files you want to restore are marked with an asterisk (*) for
extraction. If you extract a directory, all of the directory contents are marked for extraction.
In this example, two files are marked for extraction. The ls command displays an asterisk in front of the selected file names,file1 and file2.
ufsrestore > ls
./directory1:
3904 *./ 2 *../ 3905 *file1 3906 *file2 3907 file3
ufsrestore > delete file1刪除一個文件。
ufsrestore > ls
./directory1:
3904 *./ 2 *../ 3905 file1 3906 *file2 3907 file3
(4)查看被選擇的文件:
ufsrestore > marked
./directory1:
3904 *./ 2 *../ 3906 *file2
(5)解出被選擇的文件到當前目錄:
ufsrestore > extract
Extract requested files
You have not read any volumes yet.
Unless you know which volume your file(s) are on you should start with the last volume and work towards the first.
Specify next volume #: 1
extract file ./directory1/file2
Add links
Set directory mode, owner, and times.
(6)選擇權限設置方式,n為重新設置權限,y和磁帶中的備份的權限保持一致:
set owner/mode for ‘.’? [yn] n
ufsrestore > quit
(7)把恢復出來的文件移動到正確的目錄,并刪除臨時目錄:
# mv /export/home/tmp/directory1/file2 /export/home
# rm -r /export/home/tmp/directory1
介質類型 | 大致容量 |
1/2-inch reel tape | 140MB (每英寸6250B) |
1/4-inch cartridge (QIC) cartridge tape | 8GB |
8-mm cartridge tape | 40GB |
4-mm digital audio tape (DAT) cartridge tape | 24GB |
DLT 1/2-inch cartridge tape | 70GB |
LTO cartridge tape | 100GB |
SDLT cartridge tape | 160GB |
選項 | 說明 |
0~9 | 備份級別 |
f dump_file | 指定使用的磁帶設備,默認為/dev/rmt/0,如果是減號'-',則轉儲到標準輸出。 |
l | Autoload(自帶裝載),如果在備份完成之前,磁帶已用完,就等待2分鐘更換磁帶,并自帶裝載新磁帶,若2分鐘內未更換磁帶則會出現(xiàn)提示并繼續(xù)等待。 |
n | Notify,發(fā)送消息給當前在線的所有屬于sys組的用戶 |
o | Offline,備份完成,或者磁帶用完后倒帶,或彈出磁帶時,讓磁帶驅動器自動離線。 |
S | 大小估計 |
u | Update,在/etc/dumpdates文件中加入一條記錄 |
v | Verify,驗證剛剛備份的內容是否和源一樣,若不一樣,系統(tǒng)則會要求操作者插入新介質重新備份 |
W or w | Warning,這個選項忽略其他任何選項,根據(jù)/etc/dumpdates和/etc/vfstab文件的信息產(chǎn)生關于備份的提示信息 |
file_to_dump | 指定要進行備份的對象 |
選項 | 說明 |
t | 查看備份介質上的內容列表 |
r | 從備份介質出完整的文件系統(tǒng) |
x file1 file2 | 僅恢復指定的文件 |
i | 進入交互式恢復模式 |
v | 詳細模式,每恢復一個文件就會在終端屏幕上顯示文件的路徑名 |
f device | 指定磁帶設備的名字 |
上一頁12 下一頁 閱讀全文
版權聲明:本站文章來源標注為YINGSOO的內容版權均為本站所有,歡迎引用、轉載,請保持原文完整并注明來源及原文鏈接。禁止復制或仿造本網(wǎng)站,禁止在非www.sddonglingsh.com所屬的服務器上建立鏡像,否則將依法追究法律責任。本站部分內容來源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來,僅供學習參考,不代表本站立場,如有內容涉嫌侵權,請聯(lián)系alex-e#qq.com處理。
相關文章