免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2695 | 回复: 6
打印 上一主题 下一主题

我想请问大家对于Solaris怎样备份? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-08-01 08:02 |只看该作者 |倒序浏览
10可用积分
单位的服务器一直没有找到好的备份方法,我只是把每个目录都tar到磁带上,不知道还有没有别的办法.

论坛徽章:
0
2 [报告]
发表于 2007-08-01 08:10 |只看该作者
备份方法很多,如果不想增加投资可以使用tar,比tar更好的是ufsdump。
也可以购买商业的备份软件,实现无人职守的自动备份。

论坛徽章:
2
双鱼座
日期:2014-02-23 12:10:03操作系统版块每日发帖之星
日期:2015-12-17 06:20:00
3 [报告]
发表于 2007-08-01 09:51 |只看该作者
Backing Up Files and File Systems
This chapter describes the procedures for backing up file systems by using the ufsdump command.
For information on these procedures, see Backing Up Files and File System (Task Map).
For overview information about performing backups, see Chapter 45, Backing Up and Restoring File Systems (Overview).
For detailed information on ufsdump syntax, options, and arguments, see Chapter 49, UFS Backup and Restore Commands (Reference).
Backing Up Files and File System (Task Map)
Task         Description         For Instructions
1. Prepare for file system backups         Identify the file systems, the type of backup, and the tape device to be used for the backups.         Preparing for File System Backups

2. Determine the number of tapes needed to back up a file system         Determine the number of tapes that are needed for a full backup of a file system.         How to Determine the Number of Tapes Needed for a Full Backup

3. Back up your file systems         Perform a full backup of your file systems to get baseline copies of all files.
Perform an incremental backup of your file systems based on whether keeping copies of files that have changed on a daily basis is important at your site.         How to Backup a File System to Tape

Preparing for File System Backups
The preparation for backing up file systems begins with planning, which is described in Chapter 45, Backing Up and Restoring File Systems (Overview) and includes choosing the following:
        The file systems to back up
        The type of backup (full or incremental) to perform
        A backup schedule
        A tape drive
This section describes other tasks you might need to perform before you back up file systems, including the following:
        Finding names of file systems to back up
        Determining the number of tapes that are needed for a full backup
How to Find File System Names
1.        Display the contents of the /etc/vfstab file.

$ more /etc/vfstab
2.        Look in the mount point column for the name of the file system.
3.        Use the directory name listed in the mount point column when you back up the file system.
Example—Finding File System Names
The file systems to be backed up in this example are root (/), /usr, /datab, and /export/home.

$ more /etc/vfstab
#device           device             mount        FS   fsck mount   mount
#to mount         to fsck            point        type pass at boot options
#
fd                -                  /dev/fd      fd    -    no      -
/proc             -                  /proc        proc  -    no      -
/dev/dsk/c0t0d0s1 -                  -            swap  -    no      -
/dev/dsk/c0t0d0s0 /dev/rdsk/c0t0d0s0 /            ufs   1    no      -
/dev/dsk/c0t0d0s6 /dev/rdsk/c0t0d0s6 /usr         ufs   1    no      -
/dev/dsk/c0t0d0s5 /dev/rdsk/c0t0d0s5 /datab       ufs   2    yes     -
/dev/dsk/c0t0d0s7 /dev/rdsk/c0t0d0s7 /export/home ufs   2    yes     -
swap              -                  /tmp         tmpfs -    yes     -
How to Determine the Number of Tapes Needed for a Full Backup
1.        Become superuser or assume an equivalent role.
2.        Estimate the size of the backup in bytes.

# ufsdump S file-system
3.        The S displays the estimated number of bytes that are needed to do the backup.
4.        Divide the estimated size by the capacity of the tape to see how many tapes you need.
For a list of tape capacities, see Table 45–5.
Example—Determining Number of Tapes
In this example, the file system of 489,472 bytes easily fits on a 150-Mbyte tape.

# ufsdump S /export/home
489472
Backing Up a File System
The following are general guidelines for performing backups:
        Use single-user mode or unmount the file system, unless you are creating a snapshot of a file system. For information about UFS snapshots, see Chapter 47, Using UFS Snapshots (Tasks).
        Be aware that the backing up of file systems when there are directory-level operations (such as creating, removing, and renaming files) and file-level activity occurring means that some data will not be included in the backup.
        You can run the ufsdump command from a single system and remotely back up groups of systems across the network through remote shell or remote login, and direct the output to the system on which the tape drive is located. (Typically, the tape drive is located on the system from which you run the ufsdump command, but it does not have to be.)
Another way to back up files to a remote drive is to pipe the output from the ufsdump command to the dd command. For information about using the dd command, see Chapter 50, Copying UFS Files and File Systems (Tasks).
        If you are doing remote backups across the network, the system with the tape drive must have entries in its /.rhosts file for each client that will be using the drive. Also, the system that initiates the backup must be included in the /.rhosts file on each system that it will back up.
        To specify a remote tape device on a system, use the naming convention that matches the OS release of the system with the remote tape drive. For example, use the /dev/rst0 device for a remote drive on a system that is running the SunOS 4.1.1 release or compatible versions. Use the /dev/rmt/0 device for a system running the Solaris 9 release or compatible versions.
________________________________________
Note –
Use the nisbackup command to back up a NIS+ master server. For information on using this command, see System Administration Guide: Naming and Directory Services (FNS and NIS+).
________________________________________
How to Backup a File System to Tape
The following steps provide the general steps for backing up file systems using the ufsdump command. The examples show specific uses of options and arguments.
1.        Become superuser or assume an equivalent role.
2.        Bring the system to run level S (single-user mode).

# shutdown -g30 -y
3.        (Optional) Check the file system for consistency.

# fsck -m /dev/rdsk/device-name
4.        The fsck -m command checks for the consistency of file systems. For example, power failures can leave files in an inconsistent state. For more information on the fsck command, see Chapter 42, Checking UFS File System Consistency (Tasks).
5.        If you need to back up file systems to a remote tape drive:
a.        On the system to which the tape drive is attached (the tape server), add the following entry to its /.rhosts file.

host root
b.        The host entry specifies the name of the system on which you will run the ufsdump command to perform the backup.
c.        On the tape server, verify that the host added to the /.rhosts file is accessible through the name service.
6.        Identify the device name of the tape drive.
The default tape drive is the /dev/rmt/0 device.
7.        Insert a tape that is not write-protected into the tape drive.
8.        Back up file systems.

# ufsdump options arguments filenames
9.        The following examples show how to use the most common ufsdump options and arguments:
o        Example—Performing a Full Backup of root (/)
o        Example—Performing an Incremental Backup of root (/)
o        Example—Performing a Full Backup, Individual Home Directory
o        Example—Performing a Full Backup to Remote System (Solaris 9 Data to Solaris 9 System)
For other ufsdump options and arguments, see Chapter 49, UFS Backup and Restore Commands (Reference).
10.        If prompted, remove the tape and insert the next tape volume.
11.        Label each tape with the volume number, dump level, date, system name, disk slice, and file system.
12.        Bring the system back to run level 3 by pressing Control-D.
13.        Verify that the backup was successful.

# ufsrestore tf device-name
Example—Performing a Full Backup of root (/)
The following example shows how to do a full backup of the root (/) file system. The system in this example is brought to single-user mode before the backup. The following ufsdump options are included:
        0 specifies that this is a 0 level dump (or a full backup)
        u specifies that the /etc/dumpdates file is updated with the date of this backup
        c identifies a cartridge tape device
        f /dev/rmt/0 identifies the tape device
        / is the file system being backed up

# shutdown -g30 -y
# ufsdump 0ucf /dev/rmt/0 /
  DUMP: Writing 63 Kilobyte records
  DUMP: Date of this level 0 dump: Wed Sep 05 13:27:20 2001
  DUMP: Date of last level 0 dump: the epoch
  DUMP: Dumping /dev/rdsk/c0t1d0s0 (earth:/) to /dev/rmt/0.
  DUMP: Mapping (Pass I) [regular files]
  DUMP: Mapping (Pass II) [directories]
  DUMP: Estimated 57150 blocks (27.91MB).
  DUMP: Dumping (Pass III) [directories]
  DUMP: Dumping (Pass IV) [regular files]
  DUMP: Tape rewinding
  DUMP: 57076 blocks (27.87MB) on 1 volume at 265 KB/sec
  DUMP: DUMP IS DONE
  DUMP: Level 0 dump on Wed Sep 05 13:27:20 2001
  # ufsrestore tf /dev/rmt/0
         2      .
         3      ./lost+found
      3776      ./usr
      7552      ./var
     11328      ./export
     15104      ./export/home
     18880      ./etc
     22656      ./etc/default
     22657      ./etc/default/sys-suspend
     22673      ./etc/default/cron
     22674      ./etc/default/devfsadm
     22675      ./etc/default/dhcpagent
     22676      ./etc/default/fs
     22677      ./etc/default/inetinit
     22678      ./etc/default/kbd
     22679      ./etc/default/mpathd
     22680      ./etc/default/nfslogd
     22681      ./etc/default/passwd
                .
                .
                .
  # (Press Control-d to bring system to run level 3)
Example—Performing an Incremental Backup of root (/)
The following example shows how to do an incremental backup of the root (/) file system. The following ufsdump options are included:
        9 specifies that this is a 9 level dump (or an incremental backup)
        u specifies that the /etc/dumpdates file is updated with the date of this backup
        c identifies a cartridge tape device
        f /dev/rmt/0 identifies the tape device
        / is the file system being backed up

# ufsdump 9ucf /dev/rmt/0 /
  DUMP: Writing 63 Kilobyte records
  DUMP: Date of this level 9 dump: Fri Jul 13 10:58:12 2001
  DUMP: Date of last level 0 dump: Fri Jul 13 10:46:09 2001
  DUMP: Dumping /dev/rdsk/c0t0d0s0 (starbug:/) to /dev/rmt/0.
  DUMP: Mapping (Pass I) [regular files]
  DUMP: Mapping (Pass II) [directories]
  DUMP: Mapping (Pass II) [directories]
  DUMP: Mapping (Pass II) [directories]
  DUMP: Mapping (Pass II) [directories]
  DUMP: Estimated 200 blocks (100KB).
  DUMP: Dumping (Pass III) [directories]
  DUMP: Dumping (Pass IV) [regular files]
  DUMP: Tape rewinding
  DUMP: 124 blocks (62KB) on 1 volume at 8 KB/sec
  DUMP: DUMP IS DONE
  DUMP: Level 9 dump on Fri Jul 13 10:58:12 2001
# ufsrestore tf /dev/rmt/0
         2      .
         3      ./lost+found
      5696      ./usr
     11392      ./var
     17088      ./export
     22784      ./export/home
     28480      ./opt
      5697      ./etc
     11393      ./etc/default
     11394      ./etc/default/sys-suspend
     11429      ./etc/default/cron
     11430      ./etc/default/devfsadm
     11431      ./etc/default/dhcpagent
     11432      ./etc/default/fs
     11433      ./etc/default/inetinit
     11434      ./etc/default/kbd
     11435      ./etc/default/nfslogd
     11436      ./etc/default/passwd
     11437      ./etc/default/tar
                .
                .
                .
Example—Performing a Full Backup, Individual Home Directory
The following example shows how to do a full backup of the /export/home/kryten directory. The following ufsdump options are included:
        0 specifies that this is a 0 level dump (or a full backup)
        u specifies that the /etc/dumpdates file is updated with the date of this backup
        c identifies a cartridge tape device
        f /dev/rmt/0 identifies the tape device
        /export/home/kryten is the directory being backed up

# ufsdump 0ucf /dev/rmt/0 /export/home/kryten
  DUMP: Writing 63 Kilobyte records
  DUMP: Date of this level 0 dump: Fri Jul 13 11:30:45 2001
  DUMP: Date of last level 0 dump: the epoch
  DUMP: Dumping /dev/rdsk/c0t3d0s7 (pluto:/export/home) to /dev/rmt/0.
  DUMP: Mapping (Pass I) [regular files]
  DUMP: Mapping (Pass II) [directories]
  DUMP: Estimated 232 blocks (116KB).
  DUMP: Dumping (Pass III) [directories]
  DUMP: Dumping (Pass IV) [regular files]
  DUMP: Tape rewinding
  DUMP: 124 blocks (62KB) on 1 volume at 8 KB/sec
  DUMP: DUMP IS DONE
# ufsrestore tf /dev/rmt/0
         2           .
      2688           ./kryten
      5409           ./kryten/letters
      5410           ./kryten/letters/letter1
      5411           ./kryten/letters/letter2
      5412           ./kryten/letters/letter3
      2689           ./kryten/.profile
      8096           ./kryten/memos
        30           ./kryten/reports
        31           ./kryten/reports/reportA
        32           ./kryten/reports/reportB
        33           ./kryten/reports/reportC
#
Example—Performing a Full Backup to Remote System (Solaris 9 Data to Solaris 9 System)
The following example shows how to do a full backup of a local /export/home file system on a Solaris 9 system (starbug) to a tape device on a remote Solaris 9 system (earth).The following ufsdump options are included:
        0 specifies that this is a 0 level dump (or a full backup)
        u specifies that the /etc/dumpdates file is updated with the date of this backup
        c identifies a cartridge tape device
        f earth:/dev/rmt/0 identifies the remote system name and tape device
        /export/home is the file system being backed up

# ufsdump 0ucf earth:/dev/rmt/0 /export/home
  DUMP: Writing 63 Kilobyte records
  DUMP: Date of this level 0 dump: Wed Sep 05 14:52:31 2001
  DUMP: Date of last level 0 dump: the epoch
  DUMP: Dumping /dev/rdsk/c0t0d0s7 (starbug:/export/home) to earth:/dev ...
  DUMP: Mapping (Pass I) [regular files]
  DUMP: Mapping (Pass II) [directories]
  DUMP: Estimated 266 blocks (133KB).
  DUMP: Dumping (Pass III) [directories]
  DUMP: Dumping (Pass IV) [regular files]
  DUMP: Tape rewinding
  DUMP: 250 blocks (125KB) on 1 volume at 247 KB/sec
  DUMP: DUMP IS DONE
  DUMP: Level 0 dump on Wed Sep 05 14:52:31 2001
# ufsrestore tf earth:/dev/rmt/0
         2      .
         3      ./lost+found
      7168      ./rimmer
      7169      ./rimmer/.profile
     21504      ./rimmer/scdir
     21505      ./rimmer/scdir/scd557
     21506      ./rimmer/scdir/scd772
     10752      ./lister
     10753      ./lister/.profile
     10754      ./lister/filea
     10755      ./lister/fileb
     10756      ./lister/filec
     14336      ./pmorph
     14337      ./pmorph/.profile
      3584      ./pmorph/bigdir
      3585      ./pmorph/bigdir/bigfile
     17920      ./pmorph/smalldir
     17921      ./pmorph/smalldir/smallfile
#

论坛徽章:
2
双鱼座
日期:2014-02-23 12:10:03操作系统版块每日发帖之星
日期:2015-12-17 06:20:00
4 [报告]
发表于 2007-08-01 09:52 |只看该作者
磁带主要用来离线存储数据,通常用于备份。
当一个新的磁带设备连接到系统并被发现后(ok. boor –r),这个磁带设备就可以使用了。与磁盘不同,磁带设备不需要进行格式化(format),卷标识(label)等。

磁带设备的地址和逻辑设备名
-------------------------------------------------------------------------------------------------------
磁盘设备 SCSI地址(Target ID) 主逻辑设备名 附加逻辑设备名
-------------------------------------------------------------------------------------------------------
第一个磁带设备 4 /dev/rmt/0 /dev/rmt/0l
/dev/rmt/0m
/dev/rmt/0h
/dev/rmt/0u
第二个磁带设备 5 /dev/rmt/1 /dev/rmt/1l
/dev/rmt/1m
/dev/rmt/1h
/dev/rmt/1u
-------------------------------------------------------------------------------------------------------
(SCSI地址可以是总线上的唯一地址)
附加的参数表示了磁带密度
l ---------- low
m --------- medium
h --------- high
u --------- ultra

增加一个磁带机的步骤
1. 关闭系统
2. 检查磁带的SCSI地址是否设置正确
默认的,磁带机的目标地址为4,如果你有多个磁带的话,则要设置正确设置第二个磁带机,使它的SCSI地址不要与当前的地址相冲突
3. 安装磁带设备
4. 开启系统和所有外围设备(ok. boot –r)

显示一个磁带设备的状态
将磁带放入磁带机中,然后:
# mt –f /dev/rmt/0 status
如果你有多于一个磁带设备,设备则是:/dev/rmt/1, /dev/rmt/2…
你可能会看到如下信息:
Quantum DLT7000 tape drive:
sense key(0x0)= nosense residual= 0 retries= 0
file no= 0 block no= 0
sense key(0x0)= nosense表示你的系统可以正常访问磁带。
sense key(0x6)= unit attention表示这个设备可能被重置,或是刚加电的状态
sense key(0x13)= EOT 表示这个磁带可能损坏
/dev/rmt/0: no tape loaded or drive offline 此信息表示磁带不能访问

no such file or directory 如果你出现了这条信息,你的系统与你的磁带设备无法进行通讯。查看一下,磁带机是否加电,以及连线是否正常,或再次进行:ok. boot –r

磁带的重绕
# mt –f /dev/rmt/0 rewind


与磁带的读写数据有关的命令

主要包括5个命令:
cpio, dd, ufsdump, ufsrestore, tar

命令:cpio
cpio其实就是:copy in/out,从标准输入中读取要拷贝的文件,并将其写入到标准输出。这个命令是很常用的,但是要重定义标准输入和输出。当需要使用多于一个磁带时,可以使用这个命令。
1. 拷贝目录 /work及所有子目录到磁带 /dev/rmt/0
# cd /work
# ls –R | cpio –ocB > /dev/rmt/0

2. 将磁带中的文件拷贝回/work目录
# cd /work
# cpio –icBd < /dev/rmt/0

o ---- copy out,读取标准输入,获得文件列表,拷贝这些文件到标准输出
i ---- copy in,从标准输入扩展文件
c ----标识了头信息已经以ASCII方式被写入
d ----创建所需的目录
B ----这是必须使用的,标识着输入是以块的方式被记录

命令:dd
这个命令可以对不同数据格式的文件进行转换并拷贝。当从你的硬盘迁移一个文件系统或分区时可以使用这个命令。你也可以使用它来进行从一个硬盘到另一个硬盘的数据拷贝。如果拷贝时,你指定了变量块的大小,那么,你在恢复时,也要指定相同的变量块。
1. 拷贝文件系统:/user/sunsystem到一个磁盘设备:/dev/rmt/0
# dd if=/dev/dsk/c0t0d0s7 of=/dev/rmt/0 bs=63k

命令:ufsdump
这个命令可以从一个硬盘拷贝一个文件系统或目录到磁带。它被设定为备份命令,支持多个卷及增量备份。注意一下,这里,所有的文件必须是同一个文件系统的一部分或在一个分区,而且你必须是superuser
1. 将所有位于:/dev/rdsk/c0t3d0s0下的文件拷贝到一个称为:/dev/rmt/0的dump文件
# ufsdump 0uf /dev/rmt/0 /dev/rdsk/c0t3d0s0
0 ----表示dump的级别。级别0拷贝全部的文件系统到磁带中,有效的级别为0---9, 1---9执行的是增量备份,只会拷贝在当前时间后改变的文件。
u ----表示如果成功的话,则对文件:/etc/dumpdates中的dump记录使用时间戳做一次更新
f ----指定dump文件(逻辑设备名或磁带设备)。f参数后,必须要跟随一个文件名,在本例中是:/dev/rmt/0
/dev/rdsk/c0t3d0s0包含你想要将文件写入磁带的源名字。

命令:ufsrestore
这个命令从一个磁带拷贝文件系统到一个硬盘。它只能拷贝由ufsdump创建的文件。
它必须使用以下的三个参数中的一个:
i ----(交互)从介质中读取目录信息后,ufsrestore调用一个交互式接口允许你浏览dump文件的层次结构,并选择文件进行扩展
r ----(递归)将介质中的全部内容恢复到当前目录(它将是文件系统中的顶级),为了完整的恢复一个文件系统,要使用这个参数来恢复级别为0的dump,并再次恢复每个增量dump。
t ----(内容列表)提供磁带中的所有文件列表

以下的参数为不是必须的:
f ----(dump文件)指定从哪里恢复dump文件。如果dump文件没有被指定,那么,ufsrestore将使用 /dev/rmt/0
v ----(详细模式)显示从磁带中读取的路径名

1. 举个例子,如下:
# cd /work
# ufsrestore if /dev/rmt/0
ufsrestore> ?
Available commands are:
ls [arg] - list directory
cd arg - change directory
pwd - print current directory
add [arg] - add ‘arg’ to list of files to be extracted
delete [arg] - delete ‘arg’ from list of files to be extracted
extract - extract requested files
setmodes - set modes of requested directories
quit - immediately exit program
what - list dump header information
verbose - toggle verbose flag (useful with ‘‘ls’’)
help or ‘?’ - print this list
IF no ‘arg’ is supplied, the current directory is used

ufsrestore> ls
4lib/ dict mail openwin spool
5bin games man/ preserve src
adm include/ net pub tmp

使用命令:add来增加要扩展的文件和目录到文件列表
ufsrestore> add mail man

现在,从磁带中扩展这些文件,它们将被释放到你当前的工作目录:
ufsrestore> extract

当你所需要的文件被扩展后,就可以退出ufsrestore了
ufsrestore> q

命令:tar
一个tarfile通常是一个磁带,但它可能是任何文件。如果数据总量超过了一个磁带,你就需要使用一个不同的磁带命令,因为tar命令不可以跨多个卷。
1. 下例显示如果从硬盘拷贝数据到磁带
# tar cvf /dev/rmt/0 /work

参数:
c ----创建tar文件(在本例中写入到磁带)
v ----显示它所拷贝的每个文件的信息(详细模式)
f ----指定源设备名,本例中为/dev/rmt/0

2. 下例显示如何从磁带中拷贝文件到硬盘
# cd /tmp
# tar xvf /dev/rmt/0

x ----表示从tar文件中扩展文件
-------------------------------------------------------------------------
补充tar
b 指定在每一次读取和写入操作中使用的磁带块的号码
h 归档通过符号链接访问的文件
i 在档案的创建过程中忽略校验和错误
k 指定挡案大小(千字节),如果档案大于这个大小就分拆
o 将所有档案文件的用户和组所有关系修改为当前所有者

论坛徽章:
0
5 [报告]
发表于 2007-08-01 10:23 |只看该作者
谢谢蜘蛛兄

论坛徽章:
0
6 [报告]
发表于 2007-08-01 10:29 |只看该作者
ORZ!收藏!给朵鲜花!

论坛徽章:
0
7 [报告]
发表于 2007-08-01 12:58 |只看该作者
蜘蛛老大能把 包括“Backing Up Files and File Systems "这章内容的书贴出来吗?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP