Friday, March 20, 2009

Backup Script

OK, we had been talkign about database backups before I rambled off on a couple of other topics. This post is going to talk about using the Tivoli Storage Mnager admin client scripting tool to gather all the parts of the database backup into a single scheduled set of commands.

First you may ask, why the script and why not seperate schedules. The reson is that some of the steps need to occur inthe correct sequence and this makes sure that they do. For example: You do not want to take a backup of your volume history before the database backup completes or you will not have the volumes of that backup defined in it. Se here goes:

Start the script with a deletion of old database backup volumes from the volume history. This keeps the volhist file from becoming too cumbersome over time.

def script backup "del volhist todate=today-5 type=dbb" line=001

This line starts the definition of a script call backup and adds line 1 to that script. Next we will add line 2 which will do tha actual database backup.

upd script backup "ba db dev=backups t=f w=y" line=002

Line 2 to backup the database has now been added to the script. Note that to add an additional line we used the update rather than the define command. Since the script now exists, the rest o the lines must be added with this option. Also the backup is a full backup to allow it to be used on it's own for a restore. Finally not the w=y or wait=yes option on the backup commnad. This causes the script to wait and not process subsequent commands tillt he backup is complete. This is important as we do not want to backup the volume history until th evolues from the database backup have been created.

The next line will cover this exact item.

upd script backup "backup volhistory filenames=F:\TSM_Backup_Files\volhist.out" line=003

So line 3 is added to the script which creates a volume history file of all volumes in the TSM system including the ones just added by the backup. And finally line 4.

upd script backup "backup devconfig filenames=F:\TSM_Backup_Files\devconfig.out" line=004

This line will create a backup of the Tivoli Storage Manager configured devices. This is needed in case the entire database is corrupted and needs to be restored. Part of the command to restore a database is the device class parameter telling the system what device to use in accessing the backup volumes defined in the volume history. Since this info is in the database, it may not be available for a database restore. That is when this file comes in. TSM uses the information in this file to recreate the device configuration before attempting to restore the database volumes.

So now that the script is all ready, only one step remins. Putting it into the administrative schedules so that it runs on a scheduled basis to keep database backups available for a restore.

def sch BACKUPDB t=a cmd="run backup" t=a ACTIVE=y startd=04/02/2009 startt=23:00:00 dur=1 duru=h per=1 peru=D day=ANY exp=N

This will schedule the backup script to run each night at 11:00 P.M. until the system breaks down or someone tells it to stop. There are quite a few parameters on this command, and most of them are default values. I just added them to ensure you knew what was going to happen to the script.

That is enough for today. Again I am sorry I have not been adding posts as I wanted, but hope to improve in the near future. I have left the company I was affiliated with and have started to work as an independent contractor. Hopefully this works out and also leave me more time for items such as this.


  1. This comment has been removed by the author.

  2. Hi,

    I want To schedule Smitty mksysb backup in TSM server BY USING HALT command""" & after backup completion server "plz help me"