1 / 47

第 19 章 备份与恢复

第 19 章 备份与恢复. 内容概要. 了解以下关于备份的基本内容 : - 备份介质 - 备份周期 - 备份类型 能够掌握通过 SMIT 和命令行备份的备份方法 能够创建一个定制的可安装系统映像 能够执行其他有用的命令来操纵介质上的备份数据. 备份的必要性. 数据是非常重要的 — 重建数据非常昂贵 — 有些数据具有不可恢复性 保证数据毁坏后的修复 — 硬件损坏导致的数据损坏 — 安装 / 恢复时的数据损坏 — 意外删除引起的数据损坏. 备份的必要性.

inge
Download Presentation

第 19 章 备份与恢复

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 第19章 备份与恢复

  2. 内容概要 • 了解以下关于备份的基本内容: -备份介质 -备份周期 -备份类型 • 能够掌握通过SMIT和命令行备份的备份方法 • 能够创建一个定制的可安装系统映像 • 能够执行其他有用的命令来操纵介质上的备份数据

  3. 备份的必要性 • 数据是非常重要的 —重建数据非常昂贵 —有些数据具有不可恢复性 • 保证数据毁坏后的修复 —硬件损坏导致的数据损坏 —安装/恢复时的数据损坏 —意外删除引起的数据损坏

  4. 备份的必要性 • 系统之间数据的传送 • 重组文件系统 • 磁盘重组以提高性能 • 系统映像备份安装 • 系统或软件升级前后的检查点 • 作为长期的档案

  5. 备份类型 三种备份类型: • 系统备份 操作系统的映象备份(rootvg卷组) • 全备份 备份所有用户数据及配置文件 • 增量备份 记录上次完整备份以来的变化

  6. 备份所有改变的数据! 系统备份 全备份 增量备份 增量备份 备份策略

  7. 备份设备 –软盘 • /dev/fd0 内置3.5 英寸软盘驱动器 • /dev/fd1 外接3.5 英寸或5.25 英寸软盘驱动器等

  8. 备份设备-磁带 磁带设备,如 • 4mm DAT磁带驱动器(2GB 或4GB) • 8mm DAT磁带驱动器(2.3GB 或5GB) • 1/2英寸9磁道磁带驱动器(1600bpi 或6250bpi ) • DLT、VXA、QIC

  9. 备份设备-可读写光驱 • 对于只读操作可使用CD-ROM文件系统 • 对于可读写操作可使用JFS文件系统 • CD: - OEM CD-RW驱动 - 第三方软件来支持CD • DVD: - 需要7210DVD-RAM 驱动 - 不需要额外的软件来支持UDF格式

  10. 备份设备-7210外置DVD-RAM驱动 • 可写的DVD-RAM介质 • 可读 2.6 GB, 4.7 GB, 5.2 GB, and 9.4 GB的DVD • 支持 模式 1 或 2, XA, CDDA 和音频格式的 CD-ROM • 可读的多重会话硬盘, CD-R, CD-ROM, 和CD-RW盘 • 装载可容纳8 厘米和 12 厘米 介质的托盘 • 支持SCSI

  11. Logical) System Storage Management (Physical and Logical Volume Manager File Systems Files and Directories System Backup Manager Files and Directories File Systems Back Up a File or Directory Back Up a File System Restore a File or Directory Restore a File System List Contents of a Backup List Contents of a Backup Logical Volume Manager System Backup Manager Volume Groups Back Up the System Preview Information about a Backup Volume Groups Verify the Readability of a Backup Back Up a Volume Group View the Backup Log List Information about Filesets in a System Image Remake a Volume Group List Files in a Volume Group Backup List Files in a System Image Restore Files in a Volume Group Backup Restore Files in a System Image Back Up the System Back Up a Volume Group Back Up a Volume Group to Tape/File Back Up This System to Tape/File Back Up a Volume Group to CD Back Up This System to CD Back Up a Volume Group to DVD Back Up This System to DVD SMIT备份菜单

  12. 根卷组备份-mksysb • 仅备份rootvg 卷组 • 只备份已安装的文件系统 • 备份后的磁带可引导系统 • 提供非交互式的安装方式 • 保存换页空间定义 • 保存逻辑卷的分配策略 • 设置最少用户和应用活动

  13. image.data文件 包含BOS 安装工具创建rootvg卷组所需参数,如: • Logical_volume_policy: • vg_data: • source_disk_data: • lv_data: • fs_data: 做系统备份时,mksysb读取该文件,作为备份依据

  14. bosinst.data文件 /bosinst.data 文件定义了对目标系统的安装要求以及安装时用户进行交互操作的方式. Mksysb 将此文件作为 rootvg 映象的第一个文件写入磁带。 可通过定制该文件实现灵活安装目标系统。 control_flow: CONSOLE = Default INSTALL_METHOD = overwrite PROMPT = yes EXISTING_SYSTEM_OVERWRITE = yes INSTALL_X_IF_ADAPTER = yes RUN_STARTUP = yes RM_INST_ROOTS = no ERROR_EXIT = CUSTOMIZATION_FILE = TCB = no INSTALL_TYPE = …… target_disk_data: LOCATION = SIZE_MB = HDISKNAME = locale: BOSINST_LANG = CULTURAL_CONVENTION = MESSAGES = KEYBOARD =

  15. rootvg-备份系统 • smit sysbackup Back Up the System Move cursor to desired item and press Enter. Back Up This System to Tape/File Back Up This System to CD Create a Generic Backup CD or DVD Back Up This System to DVD F1=Help F2=Refresh F3=Cancel F8=Image F9=Shell F10=Exit Enter=Do

  16. rootvg-备份系统到磁带或文件 ◆ smit mksysb Back Up This System to Tape/File 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 [] +/ 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 Location of existing mksysb image [] / File system to use for temporary work space [] / (If blank, /tmp will be used.) Backup encrypted files? yes + Back up DMAPI filesystem files? yes + [BOTTOM]

  17. mksysb映像 块大小= 块大小= 块大小= 磁带驱动 512 512 512 块大小 根卷组 mkinsttape 虚拟文件 BOS 引导 映像 映像 .toc 数据 内核 ./image.data ./bosinst.data ./tapeblksz 虚拟 TOC 通过不同名称 备份 设备驱动

  18. 备份卷组 ◆ smit vgbackup Back Up a Volume Group Move cursor to desired item and press Enter. Back Up a Volume Group to Tape/File Back Up a Volume Group to CD Back Up a Volume Group to DVD F1=Help F2=Refresh F3=Cancel F8=Image F9=Shell F10=Exit Enter=Do

  19. 备份卷组到磁带或文件 ◆ smit savevg Back Up a Volume Group to Tape/File Type or select values in entry fields. Press Enter AFTER making all desired changes. [Entry Fields] WARNING: Execution of the savevg command will result in the loss of all material previously stored on the selected output medium. * Backup DEVICE or FILE [] +/ * VOLUME GROUP to back up [] + List files as they are backed up? no + Generate new vg.data file? yes + Create MAP files? no + EXCLUDE files? no + 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) Verify readability if tape device no + Backup Volume Group information files only? no + Backup encrypted files? yes + Back up DMAPI filesystem files? yes + [BOTTOM]

  20. 恢复系统备份(1/2) • 从安装或修复模式里引导系统 Welcome to Base Operating System Installation and Maintenance 1 Start Install Now With Default Settings 2 Change/Show Installation Settings and Install >> 3 Start Maintenance Mode for System Recovery 4 Configure Network Disks (iSCSI) Maintenance 1 Access A Root Volume Group 2 Copy a System Dump to Removable Media 3 Access Advanced Maintenance Functions 4 Erase Disks …. >> 6 Install from a System Backup Choose Tape Drive Tape Drive Path Name >> 1 tape/scsi/4mm/2GB /dev/rmt0

  21. 恢复系统备份(2/2) Welcome to Base Operating System Installation and Maintenance Type the number of your choice and press Enter. Choice is indicated by >>. 1 Start Install Now With Default Settings >> 2 Change/Show Installation Settings and Install 3 Start Maintenance Mode for System Recovery 4 Configure Network Disks (iSCSI) System Backup Installation and Settings Type the number of your choice and press Enter. 1 Disk(s) where you want to install hdisk0 2 Use Maps No 3 Shrink Filesystems No 0 Install with the settings listed above

  22. 重做或者恢复一个非根卷组 ◆ smit restvg Remake a Volume Group Type or select values in entry fields. Press Enter AFTER making all desired changes. [Entry Fields] * Restore DEVICE or FILE [/dev/rmt0] +/ SHRINK the filesystems? no + Recreate logical volumes and filesystems only no + PHYSICAL VOLUME names [] + (Leave blank to use the PHYSICAL VOLUMES listed in the vgname.data file in the backup image) Use existing MAP files? yes + Physical partition SIZE in megabytes [] +# (Leave blank to have the SIZE determined based on disk size) Number of BLOCKS to read in a single input [] # (Leave blank to use a system default) Alternate vg.data file [] / (Leave blank to use vg.data stored in backup image) F1=Help F2=Refresh F3=Cancel F4=List F5=Reset F6=Command F7=Edit F8=Image F9=Shell F10=Exit Enter=Do

  23. 备份映像: 软件包 文件簇 定制脚本 bosinst.data image.data 刻录映像 CD 或 DVD 系统备份-ISO9660刻录映像

  24. 软件包 文件簇 定制脚本 bosinst.data image.data UDF DVD 文件系统 系统备份 - UDF DVD 备份映像:

  25. 根卷组-备份系统到CD ◆ smit mkcd Back Up This System to CD Type or select values in entry fields. Press Enter AFTER making all desired changes. [Entry Fields] CD-R Device [] + mkysyb creation options: Create map files? no + Exclude files? no + Disable software packing of backup? no + Backup extended attributes? yes + File system to store mksysb image [] / File system to store CD file structure [] / File system to store final CD images [] / If file systems are being created: Volume Group for created file systems [rootvg] + Advanced Customization Options: Do you want the CD to be bootable? yes + Remove final images after creating CD? yes + Create the CD now? yes + Install bundle file [] / File with list of packages to copy to CD [] / Location of packages to copy to CD [] +/ Customization script [] / User supplied bosinst.data file [] / Debug output? no + User supplied image.data file [] / Backup encrypted files? yes Back up DMAPI filesystem files? Yes [BOTTOM]

  26. 根卷组-备份系统到ISO9660 DVD ◆ smit mkdvd -> 选择 1 ISO9660 (CD format) Back Up This System to ISO9660 DVD Type or select values in entry fields. Press Enter AFTER making all desired changes. [Entry Fields] DVD-R or DVD-RAM Device [] + mkysyb creation options: Create map files? no + Exclude files? no + Disable software packing of backup? no + Backup extended attributes? yes + File system to store mksysb image [] / File system to store DVD file structure [] / File system to store final DVD images [] / If file systems are being created: Volume Group for created file systems [rootvg] + Advanced Customization Options: Do you want the DVD to be bootable? yes + Remove final images after creating DVD? yes + Create the DVD now? yes + Install bundle file [] / File with list of packages to copy to DVD [] / Location of packages to copy to DVD [] +/ Customization script [] / User supplied bosinst.data file [] / Debug output? no + User supplied image.data file [] / Backup encrypted files? yes + Back up DMAPI filesystem files? yes + [BOTTOM]

  27. rootvg – 备份系统到UDF DVD Back Up This System to UDF DVD Type or select values in entry fields. Press Enter AFTER making all desired changes. [Entry Fields] DVD-RAM Device [] + mkysyb creation options: Create map files? no + Exclude files? no + Disable software packing of backup? no + Backup extended attributes? yes + File system to store mksysb image [] / (If blank, the file system will be created for you.) If file system is being created: Volume Group for created file system [rootvg] + Advanced Customization Options: Do you want the DVD to be bootable? yes + Install bundle file [] / File with list of packages to copy to DVD [] / Location of packages to copy to DVD [] +/ Customization script [] / User supplied bosinst.data file [] / Debug output? No + User supplied image.data file [] / Backup encrypted files? Yes + Back up DMAPI filesystem files? yes + [BOTTOM] ◆ smit mkdvd -> 选择 “2 UDF” (通用磁盘格式)

  28. 备份一个卷组到CD ◆ smit savevgcd Back Up a Volume Group to CD Type or select values in entry fields. Press Enter AFTER making all desired changes. [Entry Fields] CD-R Device [] + * Volume Group to back up [] + savevg creation options: Create map files? No + Exclude files? No + Disable software packing of backup? No + Backup extended attributes? Yes + File system to store savevg image [] / File system to store CD file structure [] / File system to store final CD images [] / If file systems are being created: Volume Group for created file systems [rootvg] + Advanced Customization Options: Remove final images after creating CD? Yes + Create the CD now? Yes + Debug output? No + Backup Volume Group information files only? No + Backup encrypted files? Yes + Back up DMAPI filesystem files? yes + [BOTTOM] F1=Help F2=Refresh F3=Cancel F4=List F5=Reset F6=Command F7=Edit F8=Image F9=Shell F10=Exit Enter=Do

  29. 备份一个卷组到ISO9660 DVD ◆ smit savevgdvd Back Up a Volume Group to ISO9660 DVD Type or select values in entry fields. Press Enter AFTER making all desired changes. [Entry Fields] DVD-R or DVD-RAM Device [] + * Volume Group to back up [] + savevg creation options: Create map files? no + Exclude files? no + Disable software packing of backup? no + Backup extended attributes? yes + File system to store savevg image [] / File system to store DVD file structure [] / File system to store final DVD images [] / If file systems are being created: Volume Group for created file systems [rootvg] + Advanced Customization Options: Remove final images after creating DVD? yes + Create the DVD now? yes + Debug output? no + Backup encrypted files? yes + Back up DMAPI filesystem files? yes + [BOTTOM] F1=Help F2=Refresh F3=Cancel F4=List F5=Reset F6=Command F7=Edit F8=Image F9=Shell F10=Exit Enter=Do

  30. 备份一个卷组到UDF DVD ◆ smit savevgdvd Back Up a Volume Group to ISO9660 DVD Type or select values in entry fields. Press Enter AFTER making all desired changes. [Entry Fields] DVD-RAM Device [] + * Volume Group to back up [] + savevg creation options: Create map files? no + Exclude files? no + Disable software packing of backup? no + Backup extended attributes? yes + File system to store savevg image [] / (If blank, the file system will be created for you.) If file systems are being created: Volume Group for created file systems [rootvg] + Advanced Customization Options: Debug output? no + Backup Volume Group information files only? no + Backup encrypted files? yes + Back up DMAPI filesystem files? yes + [BOTTOM] F1=Help F2=Refresh F3=Cancel F4=List F5=Reset F6=Command F7=Edit F8=Image F9=Shell F10=Exit Enter=Do

  31. 根据文件名备份 ◆ backup 命令 -q指明可移动介质已准备就绪 -v使 backup 命令显示有关备份的其他信息。 -p 对小于2GB的文件打包后备份 -U 指定备份ACL或命名的拓展属性 -Z备份加密文件系统(EFS) ◆ 文件名从标准输入内读入

  32. 根据文件名备份举例 ◆ 例1:从文件中读取要备份的文件的文件名 # cat listfile /home/roy/file1 /home/roy/file2 /home/roy/file3 # backup -iqvf /dev/rmt0 < listfile ◆ 例2:使用find命令产生要备份的文件目录 # find /home/roy | backup -iqvf /dev/rmt0 # cd /home/roy # find . | backup -iqvf /dev/rmt0 ◆ 备份文件时, 文件名所使用的相对路径或绝对路径会影响恢复文件时文件的位置

  33. 备份一个文件或目录 ◆ smit backfile Backup a File or Directory Type or select values in entry fields. Press Enter AFTER making all desired changes. [Entry Fields] This option will perform a backup by name. * Backup DEVICE [/dev/fd0] +/ * FILE or DIRECTORY to backup [.] Current working DIRECTORY [] / Backup LOCAL files only? yes + VERBOSE output? no + PACK files? no + Backup extended attributes? yes + Back up EFS Attributes? Yes + F1=Help F2=Refresh F3=Cancel F4=List F5=Reset F6=Command F7=Edit F8=Image F9=Shell F10=Exit Enter=Do

  34. 根据inode备份一个文件系统 ◆ 命令语法 # backup [-u] [-level] [-f device] filesystem • level指定不同级别进行增量备份: • -0 备份完整文件系统 • -1,-2,etc 备份最后一次level-l备份以后更改的文件 • -u 更新/etc/dumpdates文件 (/etc/dumpdates包含备份历史记录) ◆ 例: #backup -u -1 -f /dev/rmt0 /home

  35. 增量备份举例

  36. 通过SMIT根据inode备份文件系统 ◆ smit backfilesys Backup a Filesystem Type or select values in entry fields. Press Enter AFTER making all desired changes. [Entry Fields] This option will perform a backup by inode. * FILESYSTEM to backup [] +/ * Backup DEVICE [/dev/fd0] +/ Backup LEVEL (0 for a full backup) [0] # RECORD backup in /etc/dumpdates? no + * Backup extended attributes? yes + * Backup EFS attributes? yes + F1=Help F2=Refresh F3=Cancel F4=List F5=Reset F6=Command F7=Edit F8=Image F9=Shell F10=Exit Enter=Do

  37. restore 命令 (1 of 2) ◆ 列出存储介质上的文件(验证备份): # restore -T [-q] [-v] [-f device] # restore -Tvf /dev/rmt0 ◆ 恢复个别文件: #restore -x [-q] [-v] [-f device] [file1 file2 ..] # restore -xvf /dev/rmt0/home/mike/manual/chap1 ◆ 恢复完整文件系统: # restore -r [-q] [-v] [-f device] 按照备份级别按顺序恢复: 先恢复-0级, 然后-1级…… • # restore -rqvf /dev/rmt0

  38. restore 命令 (2 of 2) ◆ 仅恢复文件的属性,不恢复文件内容: # restore -Pstring [-q] [-v] [-f device] [file1 file2 ...] string 可以是: A 恢复全部属性 a 仅恢复文件的许可权 o 仅恢复文件的所有权 t 仅恢复文件的时间戳记 c 仅恢复文件的 ACL属性 ◆ 从存档里仅恢复文件/etc/passwd的许可权: # restore -Pa -vf /dev/rmt0 ./etc/passwd ◆ 显示存档中文件/etc/passwd的许可权: # restore -Ta -vf /dev/rmt0 ./etc/passwd

  39. 恢复一个文件或目录 ◆ smit restfile Restore a File or Directory Type or select values in entry fields. Press Enter AFTER making all desired changes. [Entry Fields] * Restore DEVICE [/dev/fd0] +/ * Target DIRECTORY [.] / FILE or DIRECTORY to restore [] (Leave blank to restore entire archive.) VERBOSE output? no + Number of BLOCKS to read in a single input [] # operation Restore Extended Attributes? yes + F1=Help F2=Refresh F3=Cancel F4=List F5=Reset F6=Command F7=Edit F8=Image F9=Shell F10=Exit Enter=Do

  40. 其他 UNIX 备份命令 ◆ tar 命令(tape archive缺省备份到磁带) -可用性好 -适合跨平台传输数据 ◆ cpio 命令(将输入复制到输出) -可用性好 -对于大量软连接的处理不好 ◆ dd 命令(设备到设备) -所备份的副本为完整映像 -也可用于转换文件 例如: 把文件从 ASCII 转换成 EBCDIC

  41. tar 命令 ◆ 备份: # tar -cvf /dev/rmt0.3 /home ◆ 从 tar 文件中恢复: # tar -xvf /dev/rmt0 /home/team01/mydir ◆ 列出 tar 文件所包含的文件目录: # tar -tvf /dev/rmt0

  42. cpio 命令 ◆ 备份: # find /home | cpio -ov> /dev/rmt0 ◆ 从 cpio 映像中恢复: # cpio -idv </dev/rmt0 ◆ 列出 cpio 映像所包含的文件目录: # cpio -itv < /dev/rmt0

  43. dd 命令 ◆ dd 命令转换并复制文件 ◆ 复制文件到软盘 # dd if=/etc/inittab of=/dev/rfd0 ◆ 把文件从 ASCII 编码转换成 EBCDIC 编码 # dd if=text.ascii of=text.ebcdic conv=ebcdic ◆ 把文件内容转换成大写之母 # cat lcase.data | dd conv=ucase

  44. 控制磁带 tctl rewind 倒带 fsf N 向前跳 bsf N 向后跳 offline 弹出磁带 rewoffl 倒带并弹出 # tctl -f /dev/rmt0 rewind # tctl -f /dev/rmt0.1 fsf 3 # tctl -f /dev/rmt0 rewoffl ◆ restore -s # restore -s 4 -xvf /dev/rmt0.1 ./etc/inittab

  45. 使用磁带的好习惯 ◆ 检查备份 ◆ 检查磁带设备 ◆ 保留旧备份 ◆ 异地安全存储 ◆ 给磁带加标签 ◆ 在恢复之前先测试

  46. 课堂练习 • 下列两个命令有哪些不同? • find /home/fred | backup -ivf /dev/rmt0 • cd /home/fred; find . | backup -ivf /dev/rmt0 • ___________________________________________________ • ___________________________________________________ • ___________________________________________________ • 在一个mksysb磁带上, 先后执行 tctl rewind 和 tctl -f/dev/rmt0.1 fsf 3 命令, 你将会看到磁带上那个位置?______________________________________________________ ______________________________________________________ • 那个命令用来恢复文件? ______________________________________________________ • 判断题. 命令 smit mksysb 备份全部已挂载的文件系统. ______________________________________________________

  47. 课堂练习答案 • 下列两个命令有哪些不同? • find /home/fred | backup -ivf /dev/rmt0 • cd /home/fred; find . | backup -ivf /dev/rmt0 • (a)使用绝对路径备份文件; • (b)使用相对路径备份文件; • 所以(b)中所备份的文件可以被恢复到任意目录下 • 在一个mksysb磁带上, 先后执行 tctl rewind 和 tctl -f/dev/rmt0.1 fsf 3 命令, 你将会看到磁带上那个位置? • 应该处于所备份文件映像的开始位置, 跳过了磁带的引导区 • 哪个命令用来恢复文件? restore 命令 • 判断题. 命令 smit mksysb 备份全部已挂载的文件系统. • mksysb 命令只备份rootvg文件系统. 若要备份全部卷组应使用 savevg 命令.

More Related