Вы находитесь на странице: 1из 8

Db2OfflineBackup

check any applications connect to DB

by
db2 list applications show detail

if any running ( check for db2bp process)


db2 force applications all

db2stop force

and

db2start

take backup by using following command ( from DB2 server as instance owner)

db2 backup db <dbname> to <target directory>

from db2 command window , if NT/Unix

db2 list utilities show detail

BACKUP DATABASE Command

Creates a backup copy of a database or a table space.

Scope

This command only affects the database partition on which it is executed.

Authorization

One of the following:

 sysadm
 sysctrl
 sysmaint

Required connection
Database. This command automatically establishes a connection to the specified
database.

Note:
If a connection to the specified database already exists, that connection will be terminated
and a new connection established specifically for the backup operation. The connection is
terminated at the completion of the backup operation.
Command syntax
>>-BACKUP--+-DATABASE-+--database-alias------------------------->
'-DB-------'

>--+-------------------------------------+---------------------->
'-USER--username--+-----------------+-'
'-USING--password-'

>--+---------------------------------------+--+--------+-------->
| .-,---------------. | '-ONLINE-'
| V | |
'-TABLESPACE--(----tablespace-name-+--)-'

>--+------------------------+----------------------------------->
'-INCREMENTAL--+-------+-'
'-DELTA-'

>--
+-----------------------------------------------------------------------
------------------+-->
+-USE--+-TSM--+--+-------------------------------+--
+------------------------------+------+
| '-XBSA-' '-2 OPTIONS--+-2 "options-string"-+-' '-OPEN--num-
sessions--SESSIONS-' |
| '-2 @--2 file-name-----'
|
| .-,-------.
|
| V |
|
+-TO----+-dir-+-
+-----------------------------------------------------------------------
--+
| '-dev-'
|
'-LOAD--library-name--+-------------------------------+--
+------------------------------+-'
'-2 OPTIONS--+-2 "options-string"-+-' '-OPEN--
num-sessions--SESSIONS-'
'-2 @--2 file-name-----'

>--+----------------------------+--+---------------------+------>
'-WITH--num-buffers--BUFFERS-' '-BUFFER--buffer-size-'

>--+----------------+------------------------------------------->
'-PARALLELISM--n-'
>--+------------------------------------------------------------------
+-->
'-4 COMPRESS--+-----------------------------+--+-------------------
+-'
'-4 COMPRLIB--4 name--+---------+-' '-4 COMPROPTS--4
string-'
'-4 EXCLUDE-'

.-7 EXCLUDE LOGS-.


>--+------------------------------------+--+--------------+----->
'-2 UTIL_IMPACT_PRIORITY--+----------+-' '-7 INCLUDE LOGS-'
'-2 priority-'

>--+-------------------+---------------------------------------><
'-WITHOUT PROMPTING-'

Command parameters
DATABASE database-alias
Specifies the alias of the database to back up.
USER username
Identifies the user name under which to back up the database.
USING password
The password used to authenticate the user name. If the password is omitted, the
user is prompted to enter it.
TABLESPACE tablespace-name
A list of names used to specify the table spaces to be backed up.
ONLINE
Specifies online backup. The default is offline backup. Online backups are only
available for databases configured with logretain or userexit enabled. During an
online backup, DB2 obtains IN (Intent None) locks on all tables existing in SMS
table spaces as they are processed and S (Share) locks on LOB data in SMS table
spaces.
INCREMENTAL
Specifies a cumulative (incremental) backup image. An incremental backup
image is a copy of all database data that has changed since the most recent
successful, full backup operation.
DELTA
Specifies a non-cumulative (delta) backup image. A delta backup image is a copy
of all database data that has changed since the most recent successful backup
operation of any type.
USE TSM
Specifies that the backup is to use Tivoli Storage Manager output.
USE XBSA
Specifies that the XBSA interface is to be used. Backup Services APIs (XBSA)
are an open application programming interface for applications or facilities
needing data storage management for backup or archiving purposes.
22
OPTIONS
2
277
"options-string"
7
Specifies options to be used for the backup operation.The string will 7 be passed
to the vendor support library, for example TSM, exactly as it was 7 entered,
without the quotes. 7 7 7
Note:
7
Specifying this option overrides the value specified by the VENDOROPT 7
database configuration parameter.
7
277
@file-name
7
Specifies that the options to be used for the backup operation are contained 7 in a
file located on the DB2 server. The string will be passed to the vendor support
library, for example 7 TSM. The file must be a fully qualified file name. 7
222
OPEN num-sessions SESSIONS
The number of I/O sessions to be created between DB2 and TSM or another
backup vendor product.
Note:
This parameter has no effect when backing up to tape, disk, or other local device.
TO dir/dev
A list of directory or tape device names. The full path on which the directory
resides must be specified. If USE TSM, TO, and LOAD are omitted, the default
target directory for the backup image is the current working directory of the client
computer. This target directory or device must exist on the database server. This
parameter can be repeated to specify the target directories and devices that the
backup image will span. If more than one target is specified (target1, target2, and
target3, for example), target1 will be opened first. The media header and special
files (including the configuration file, table space table, and history file) are
placed in target1. All remaining targets are opened, and are then used in parallel
during the backup operation. Because there is no general tape support on
Windows operating systems, each type of tape device requires a unique device
driver. To back up to the FAT file system on Windows operating systems, users
must conform to the 8.3 naming restriction.

Use of tape devices or floppy disks might generate messages and prompts for user
input. Valid response options are:

c
Continue. Continue using the device that generated the warning message (for
example, when a new tape has been mounted)
d
Device terminate. Stop using only the device that generated the warning message
(for example, when there are no more tapes)
t
Terminate. Abort the backup operation.

If the tape system does not support the ability to uniquely reference a backup
image, it is recommended that multiple backup copies of the same database not be
kept on the same tape.

LOAD library-name
The name of the shared library (DLL on Windows operating systems) containing
the vendor backup and restore I/O functions to be used. It can contain the full
path. If the full path is not given, it will default to the path on which the user exit
program resides.
77
WITH num-buffers BUFFERS
7
The number of buffers to be used. DB2 will automatically choose 7 an optimal
value for this parameter unless you explicitly enter a value. 7 However, when
creating 7 a backup to multiple locations, a larger number of buffers can be used
to 7 improve performance. 7
77
BUFFER buffer-size
7
The size, in 4 KB pages, of the buffer used when building the backup 7 image.
DB2 will automatically choose 7 an optimal value for this parameter unless you
explicitly enter a value. 7 The minimum value for this parameter is 8 pages. 7 7

If using tape with variable block size, reduce the buffer 7 size to within the range
that the tape device supports. Otherwise, the backup 7 operation might succeed,
but the resulting image might not be recoverable.

When using tape devices on SCO UnixWare 7, specify a buffer size of 16.

With most versions of Linux, using DB2's default buffer size for backup
operations 7 to a SCSI tape device results in error SQL2025N, reason code 75. To
prevent 7 the overflow of Linux internal SCSI buffers, use this formula:

7
bufferpages <= ST_MAX_BUFFERS * ST_BUFFER_BLOCKS / 4
where bufferpages is the value you want to use with the BUFFER 7 parameter,
and ST_MAX_BUFFERS and ST_BUFFER_BLOCKS are 7 defined in the Linux kernel
under the drivers/scsi directory.

7
77
PARALLELISM n
7
Determines the number of table spaces which can be read in parallel 7 by the
backup utility. DB2 will automatically choose 7 an optimal value for this
parameter unless you explicitly enter a value. 7
22
UTIL_IMPACT_PRIORITY priority
2
Specifies that the backup will run in throttled mode, with the priority 2 specified.
Throttling allows you to regulate the performance impact of the 2 backup
operation. Priority can be any number between 1 and 100, with 1 representing 2
the lowest priority, and 100 representing the highest priority. If the
UTIL_IMPACT_PRIORITY 2 keyword is specified with no priority, the backup
will run with the default 2 priority of 50. If UTIL_IMPACT_PRIORITY is not
specified, the backup will 2 run in unthrottled mode. An impact policy must be
defined by setting the util_impact_lim configuration parameter for 2 a backup to
run in throttled mode. 2
44
COMPRESS
4
Indicates that the backup is to be compressed. 4 4 4
COMPRLIB name
4
Indicates the name of the library to be used to perform the compression. 4 The
name must be a fully qualified path referring to a file on the server. 4 If this
parameter is not specified, the default DB2 compression library will 4 be used. If
the specified library cannot be loaded, the backup will fail. 4
4
EXCLUDE
4
Indicates that the compression library will not be stored in the backup 4 image. 4
4
COMPROPTS string
4
Describes a block of binary data that will be passed to the initialization 4 routine
in the compression library. DB2 will pass this string directly from 4 the client to
the server, so any issues of byte reversal or code page conversion 4 will have to
be handled by the compression library. If the first character 4 of the data block is
'@', the remainder of the data will be interpreted by 4 DB2 as the name of a file
residing on the server. DB2 will then replace 4 the contents of string with the
contents of this file and will pass this 4 new value to the initialization routine
instead. The maximum length for string is 1024 bytes. 4
44
77
EXCLUDE LOGS
7
Specifies that the backup image should not include any log files. 7 7 7
Note:
7
When performing an offline backup operation, logs are excluded whether or 7 not
this option is specified.
7
77
INCLUDE LOGS
7
Specifies that the backup image should include the range of 7 log files required to
restore and roll forward this image to some consistent 7 point in time. This option
is not valid for an offline backup. 7
WITHOUT PROMPTING
Specifies that the backup will run unattended, and that any actions which
normally require user intervention will return an error message.
Examples
1. In the following example, the database WSDB is defined on all 4 partitions,
numbered 0 through 3. The path /dev3/backup is accessible from all partitions.
Partition 0 is the catalog partition, and needs to be backed-up separately since this
is an offline backup. To perform an offline backup of all the WSDB database
partitions to /dev3/backup, issue the following commands from one of the
database partitions:
2. db2_all '<<+0< db2 BACKUP DATABASE wsdb TO /dev3/backup'
db2_all '|<<-0< db2 BACKUP DATABASE wsdb TO /dev3/backup'

In the second command, the db2_all utility will issue the same backup command
to each database partition in turn (except partition 0). All four database partition
backup images will be stored in the /dev3/backup directory.

3. 7 In the following example database SAMPLE is backed up to a TSM server 7


using two concurrent TSM client sessions. 7 DB2 calculates the optimal buffer
size for this environment. 7 7

db2 backup database sample use tsm open 2 sessions with 4


buffers
4. In the following example, a table space-level backup of table spaces (syscatspace,
userspace1) of database payroll is done to tapes.
5.
6. db2 backup database payroll tablespace (syscatspace,
userspace1) to
/dev/rmt0, /dev/rmt1 with 8 buffers without prompting
7. 3 The USE TSM OPTIONS keywords can be used to specify the TSM
information 3 to use for the backup operation. The following example shows how
to 3 use the USE TSM OPTIONS keywords to specify a fully qualified file name:
33

db2 backup db sample use TSM options @/u/dmcinnis/myoptions.txt

3 The file myoptions.txt contains the following 3 information: -fromnode=bar


-fromowner=dmcinnis

8. Following is a sample weekly incremental backup strategy for a recoverable


database. It includes a weekly full database backup operation, a daily non-
cumulative (delta) backup operation, and a mid-week cumulative (incremental)
backup operation:
9. (Sun) db2 backup db sample use tsm
10. (Mon) db2 backup db sample online incremental delta use tsm
11. (Tue) db2 backup db sample online incremental delta use tsm
12. (Wed) db2 backup db sample online incremental use tsm
13. (Thu) db2 backup db sample online incremental delta use tsm
14. (Fri) db2 backup db sample online incremental delta use tsm
(Sat) db2 backup db sample online incremental use tsm
15. 7 In the following example, three identical target directories are 7 specified for a
backup operation on database SAMPLE. You might 7 want to do this if the target
file system is made up of multiple physical 7 disks. 7 7

db2 backup database sample to /dev3/backup, /dev3/backup,


/dev3/backup

7 The data will be concurrently backed up to the three target directories, 7 and
three backup images will be generated with extensions .001, 7 .002, and .003.

Related reference
 RESTORE DATABASE Command
 ROLLFORWARD DATABASE Command

This topic can be found in: Command Reference.

Db2 list history backup all for pp1

Вам также может понравиться