mksysb命令进行rootvg备份

使用mksysb命令可以把系统备份到磁带上,精确的说法是mksysb主要用于创建rootvg上已挂接文件系统(mounted file systems)的可引导映像(bootable image),并可用于系统崩溃时的状态恢复。需要注意的是,这里的可引导映像不包含以下类别:



1、用户定义的页面空间(User-defined paging spaces)
2、未挂接的文件系统(unmounted file systems)
3、裸设备(raw devices)



当使用mksysb时,有时需要把一些数据文件系统排除在映像之外,可通过编辑
/etc/exclude.rootvg文件来实现,比如我要排除/tmp:



# cat /etc/exclude.rootvg



^./tmp/



然后使用-e标志来执行mksysb



# mksysb -e /dev/rmt0
Creating information file (/image.data) for rootvg.
Creating tape boot image..............
bosboot: Boot image is 29316 512 byte blocks.
Creating list of files to back up.
Backing up 2679 files.....
2679 of 2679 files (100%)
0512-038 mksysb: Backup Completed Successfully.
bosboot: Boot image is 29316 512 byte blocks.



我这里排除的文件系统如下:



ERPDB1@/home/oracle>cat /etc/exclude.rootvg
^./backup_softs/
^./orasofts_bak/
^./orabak/
^./ora_arch/



备份方法:可通过smitty窗口或直接用命令行:
1,aix下可通过smitty mksysb -> Backup Device or File 选项设置备份目标地址(可选择磁带设备或文件系统),这里也可设置其他参数:



ERPDB1@/home/oracle>smitty mksysb




Back Up the System



Type or select values in entry fields.
Press Enter AFTER making all desired changes.



[Entry Fields]
    WARNING:  Execution of the mksysb command will
              result in the loss of all material
              previously stored on the selected
              output medium. This command backs
              up only rootvg volume group.



* Backup DEVICE or FILE                              [/dev/rmt0]
  Create MAP files?                                   no
  EXCLUDE files?                                      no
  List files as they are backed up?                   no
  Verify readability if tape device?                  no 
  Generate new /image.data file?                      yes
  EXPAND /tmp if needed?                              no
  Disable software packing of backup?                 no
  Backup extended attributes?                         yes
  Number of BLOCKS to write in a single output       []  
     (Leave blank to use a system default)



注意这里的EXCLUDE files?要设置为yes才能使上面的/etc/exclude.rootvg文件指定的排除文件生效。



第二种方式就是直接用命令行了,效果一样:



/usr/bin/mksysb -i  -e /dev/rmt0



要注意的是要选择好备份的时间,因为在备份过程中,应用程序可能会增删一些文件导致备份无法完全成功,这里记录一下碰到过的错误:



Creating information file (/image.data) for rootvg.



Creating tape boot image.......
bosboot: Boot image is 36911 512 byte blocks.



Creating list of files to back up..
Backing up 148474 files..............................
4301 of 148474 files (2%)..............................
23191 of 148474 files (15%)..............................
30763 of 148474 files (20%)..............................
34831 of 148474 files (23%)..............................
68121 of 148474 files (45%)..............................
68402 of 148474 files (46%)..............................
71022 of 148474 files (47%)..............................
81052 of 148474 files (54%)..............................
94251 of 148474 files (63%)..............................
100426 of 148474 files (67%)..............................
117739 of 148474 files (79%)..............................
131841 of 148474 files (88%)..............cannot access ./etc/perf/daily/xmwlm.090114: A file or directory in the path name does not
exist.
.....
0512-003 mksysb may not have been able to archive some files.
The messages displayed on the Standard Error contained additional
information.



这是因为/etc/perf/daily/ 下的文件只保留7天,可能备到那个文件的时候正好被删除了,所以提示找不到。还碰到过这样的提示:



78871 of 144459 files (54%).........cannot access ./u01/agent10g/sysman/emd/upload/rawdata.dat: A file or directory in the path name
does not exist.
cannot access ./u01/agent10g/sysman/emd/upload/mgmt_ha_mttr.dat: A file or directory in the path name does not exist.





后来查看:



p5b1@/#ls -l /u01/agent10g/sysman/emd/upload/rawdata.dat
-rw-r-----   1 oracle   oinstall      29912 Jan 22 08:35 /u01/agent10g/sysman/emd/upload/rawdata.dat
p5b1@/#ls -l /u01/agent10g/sysman/emd/upload/mgmt_ha_mttr.dat
ls: 0653-341 The file /u01/agent10g/sysman/emd/upload/mgmt_ha_mttr.dat does not exist.



看来有一个文件是存在的,估计是备份的时间之后才生成的。这是oracle的oem相关的动态文件,应该不影响恢复。

请使用浏览器的分享功能分享到微信等