MainframeSupports
tip week 22/2002:

Sometimes it happens that you loose data in a dataset. Then you have a backup, of course. But how do you restore the right backup? Will it be useable? Most installations use HSM for backup purposes. The typical setup is that HSM takes a backup every time the dataset has been changed within the last 24 hours. Often there is three generations of backup datasets, which makes it possible to restore data as they were three changes ago.

It is possible though that there doesn't exist a HSM backup of the dataset you require. For instance no installations takes HSM backup's of their DB2-datasets, because DB2 has its own backup philosophy, as you might well know. The easiest way to determine whether a HSM backup is available or not is to issue the command TSO HLIST DA(<datasetname>) BCDS. This command lists all backup generations of the dataset. The datasetname is of course not required to exist because it might be deleted.

For every backup generation the list contains information about when it was taken, a generation number and a version number. The newest backup always has generation number 0, the previous number 1 and so forth. The first backup ever taken got version number 1 the next number 2 and so forth. When you are going to restore the dataset, you can use the backup date, the version number or the generation number. The restore is issued with command TSO HRECOVER <datasetname> GEN(0) if you want the newest backup of <datasetname>. If the dataset already exists the command will fail. If you really want the existing dataset to be overwritten, you must specify option REPLACE when issuing the command.

Maybe the lost data is a member in a partitioned dataset and it is only this member, you want to restore. The you can restore the dataset to another name using the command TSO HRECOVER <datasetname> GEN(0) NEWNAME(<new-datasetname>) where <new-datasetname> has to be a non-existing dataset. The backup is now restored in a dataset with the name <new-datasetname>. Now you can identify the lost member and eventually copy it to the original dataset. The NEWNAME option makes it possible for you to restore data from all the datasets you can read even though you can't update them.

Instead of GEN(0) for the newest backup you can specify GEN(1) for the previous backup and so forth. You can replace this option with DATE(<backup-date>) or with VER(<version-number>). You can specify an additional option called NOWAIT or WAIT. NOWAIT is the default and sends the restore off to be processed in the background and frees your TSO session to do other work. When HSM has finished the restore you will receive a NOTIFY just like from a batch job or from other HSM commands. If you specify WAIT you will have to wait for the restore to complete.

The names <datasetname> and <new-datasetname> follows the rules for TSO dataset prefixing.

Previous tip in english        Sidste danske tip        Tip list