Oracle® Database Backup and Recovery Advanced User's Guide 10g Release 2 (10.2) Part Number B14191-02 |
|
|
View PDF |
A raw device is a disk or partition that does not have a file system. In other words, a raw device can contain only a single file. Backing up files on raw devices poses operating system specific issues. The following sections discuss some of these issues on two of the most common operating systems supporting Oracle: UNIX and Windows.
See Also:
Oracle Real Application Clusters Installation and Configuration Guide for a general overview of raw devices as they relate to Oracle Real Application ClustersWhen backing up to or from raw devices, the UNIX dd
command is the most common backup utility. See your operating system specific documentation for complete details about this utility.
Using dd
effectively requires specifying the correct options, based on your database. Details about your database that affect the options you use for dd are listed in the following table.
Data | Explanation |
---|---|
Block size | You can specify the size of the buffer that dd uses to copy data. For example, you can specify that dd should copy data in units of 8 KB or 64 KB. Note that the block size for dd need not correspond to either the Oracle block size or the operating system block size: it is merely the size of the buffer used by dd when making the copy. |
Raw offset | On some systems, the beginning of the file on the raw device is reserved for use by the operating system. This storage space is called the raw offset. Oracle should not back up or restore these bytes. |
Size of Oracle block 0 |
At the beginning of every Oracle file, the operating system-specific code places an Oracle block called block 0. The generic Oracle code does not recognize this block, but the block is included in the size of the file on the operating system. Typically, this block is the same size as the other Oracle blocks in the file. |
The information in the preceding table enables you to set the dd
options specified in Table 17-1.
Table 17-1 Options for dd Command
This option ... | Specifies ... |
---|---|
|
The name of the input file, that is, the file that you are reading. |
|
The name of the output file, that is, the file to which you are writing. |
|
The buffer size used by |
|
The number of |
|
The number of |
|
The number of blocks on the input raw device for Remember to include block |
Because a raw device can be the input or output device for a backup, you have four possible scenarios for the backup. The possible options for dd
depend on which scenario you choose, as illustrated in Table 17-2.
Table 17-2 Scenarios Involving dd Backups
Backing Up from ... | Backing Up to ... | Options Specified for dd Command |
---|---|---|
Raw device |
Raw device |
|
Raw device |
File system |
|
File system |
Raw device |
|
File system |
File system |
|
For these examples of dd
utility usage, assume the following:
You are backing up a 30720 KB datafile.
The beginning of the datafile has a block 0 of 8 KB.
The raw offset is 64 KB.
You set the dd
block size to 8 KB when a raw device is involved in the copy.
In the following example, you back up from one raw device to another raw device:
% dd if=/dev/rsd1b of=/dev/rsd2b bs=8k skip=8 seek=8 count=3841
In the following example, you back up from a raw device to a file system:
% dd if=/dev/rsd1b of=/backup/df1.dbf bs=8k skip=8 count=3841
In the following example, you back up from a file system to a raw device:
% dd if=/backup/df1.dbf of=/dev/rsd2b bs=8k seek=8
In the following example, you back up from a file system to a file system, and so can set the block size to a high value to boost I/O performance:
% dd if=/oracle/dbs/df1.dbf of=/backup/df1.dbf bs=1024k
Like UNIX, Windows supports raw disk partitions in which the database can store datafiles, online logs, and control files. Each raw partition is assigned either a drive letter or physical drive number and does not contain a file system. As in UNIX, each raw partition on NT is mapped to a single file.
NT differs from UNIX in the naming convention for Oracle files. On NT, raw datafile names are formatted as follows:
\\.\drive_letter: \\.\PHYSICALDRIVEdrive_number
For example, the following are possible raw filenames:
\\.\G: \\.\PHYSICALDRIVE3
Note that you can also create aliases to raw filenames. The standard Oracle database installation provides a SETLINKS
utility that can create aliases such as \\.\Datafile12
that point to filenames such as \\.\PHYSICALDRIVE3
.
The procedure for making user-managed backups of raw datafiles is basically the same as for copying files on an NT file system, except that you should use the Oracle OCOPY
utility rather than the NT-supplied copy.exe
or ntbackup.exe
utilities. OCOPY
supports 64-bit file I/O, physical raw drives, and raw files. Note that OCOPY
cannot back up directly to tape.
To display online documentation for OCOPY
, enter OCOPY
by itself at the Windows prompt. Sample output follows:
Usage of OCOPY: ocopy from_file [to_file [a | size_1 [size_n]]] ocopy -b from_file to_drive ocopy -r from_drive to_dir
Note the important OCOPY
options described in the following table.
This option ... | Specifies ... |
---|---|
b |
Splits the input file into multiple output files. This option is useful for backing up to devices that are smaller than the input file. |
r |
Combines multiple input files and writes to a single output file. This option is useful for restoring backups created with the -b option. |
In this example, assume the following:
Datafile 12
is mounted on the \\.\G:
raw partition.
The C:
drive mounts a file system.
The database is open.
To back up the datafile on the raw partition \\.\G:
to a local file system, you can run the following command at the prompt after placing datafile 12
in backup mode:
OCOPY "\\.G:" C:\backup\datafile12.bak
In this example, assume the following:
\\.\G:
is a raw partition containing datafile 7
The A:
drive is a removable disk drive.
The database is open.
To back up the datafile onto drive A:
, you can execute the following command at the NT prompt after placing datafile 7 in backup mode:
# first argument is filename, second argument is drive OCOPY -b "\\.\G:" A:\
When drive A:
fills up, you can use another disk. In this way, you can divide the backup of datafile 7 into multiple files.
Similarly, to restore the backup, take the tablespace containing datafile 7 offline and run this command:
# first argument is drive, second argument is directory OCOPY -r A:\ "\\.\G:"