DB2:Backup

From PIT (Practical IT) Wiki
Jump to navigation Jump to search

Backups on DB2 LUW

Backups can be processed in several ways and destinations.

several ways
Mode Target
offine - no applications should be connected everybody should be offline except the backup utility to file Storage (e.g. a backup folder)
online - applications are allowed, updates vduring backup should be taken care of to Tivoli Storage (if any installed)

Only users in group db2iadm1 will be allowed to run a backup. It is recommended to use the instance owner db2inst1 for this purpose.Depending on the environment and the DB Server structure (HADR, nonHADR, encryption, etc) a different set of commands will be used to run a successful backup.

A backup file is dedicated to be used on the OS it is produced. In case you want to move your data from AIX to a Windows based DB Server it won't work. This is due to the internal structure of a backup file produced on a specific operating system.

A simple backup of a given database may look like this (the example database is named "HHDB":

$ db2 backup database HHDB compress

This command will start with some defaults:

  • The backup file will be created in the current directory. (Be sure you are in the correct folder)
  • It will be an offline backup
  • If it is taken on AIX it will be limited DB2 systems on AIX (Again: You can't migrate via backup, please keep in mind)
  • It will contain archive logs (only if archive logging is activated in the configuration of the database)
  • The restored database will be in ROLLFORWARD PENDING state
  • Without ROLLFORWARD there will be no CONNECT possible

For a complete list of possible parameters and defaults in the current DB2 LUW version, please consult the Command Reference link below.

In order to check the backup file you created you may us the helpful command:

$ db2ckbkp -H <name_of backup_file>

This will provide information about the backup time, file format, structure and much more to stdout. (Use -H to suppress a complete walkthrough in the backup file, you would be bored.)For any problem you may experience: have a search on Amber Crook's Blog (see links below). I never had a problem that was not covered, interpreted and solved by Amber. She is a true coach and a source of wisdom when it comes to DB2 challenges. Follow her in social media, you will be impressed.


Helpful links

Command Reference at IBM

Ember Crooks (IBM DB2 Gold Consultant) on backups

Ember Crooks on backup strategy