标题: 我想请问大家对于Solaris怎样备份? [打印本页] 作者: ffzbluesky 时间: 2007-08-01 08:02 标题: 我想请问大家对于Solaris怎样备份? 单位的服务器一直没有找到好的备份方法,我只是把每个目录都tar到磁带上,不知道还有没有别的办法.作者: race 时间: 2007-08-01 08:10
备份方法很多,如果不想增加投资可以使用tar,比tar更好的是ufsdump。
也可以购买商业的备份软件,实现无人职守的自动备份。作者: 东方蜘蛛 时间: 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
这个命令可以从一个硬盘拷贝一个文件系统或目录到磁带。它被设定为备份命令,支持多个卷及增量备份。注意一下,这里,所有的文件必须是同一个文件系统的一部分或在一个分区,而且你必须是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
命令: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 将所有档案文件的用户和组所有关系修改为当前所有者作者: ffzbluesky 时间: 2007-08-01 10:23
谢谢蜘蛛兄作者: xidian2002 时间: 2007-08-01 10:29
ORZ!收藏!给朵鲜花!作者: estar 时间: 2007-08-01 12:58
蜘蛛老大能把 包括“Backing Up Files and File Systems "这章内容的书贴出来吗?