How to use IF statement along with day of week in TSM script?

TMan

Newcomer
Joined
Mar 10, 2006
Messages
4
Reaction score
0
Points
0
Location
Austin, TX
Website
Visit site
Hey all!

I have recently migrated from an AIX TSM instance to Windows TSM. I'm now converting all my AIX scripts to TSM scripts where possible, but can't find a lot of documentation on how to apply logic within TSM scripts.

So, on my daily maintenance script, I'd like to backup storage pools, run a DB backup, run a prepare and then eject DRM tapes on weekdays. Something like:

if (??day of week is Saturday or Sunday??) goto expire
q drm t* wherestate=mountable > /path/file
move drm t* wherestate=mountable remove=bulk tostate=vault
expire: expi i
exit

Can anyone show how to accomplish the ??day of week is Saturday or Sunday?? part of this? Any pointers to better docs/guides for TSM scripting would also be much appreciated!

Otherwise, I figure I'll just have to have a script scheduled for Mon-Fri and a script without the DRM statements scheduled for Sat-Sun.

Thanks in advance,
TMan
 
TSM scripts are very limited but you can do the following with your example (days of week start with Sunday as 1)

select server_name from status where dayofweek(current_timestamp) in (7,1)
if(rc_ok) goto expire
q drm t* wherestate=mountable > /path/file
move drm t* wherestate=mountable remove=bulk tostate=vault
expire: expi i
exit

More generally you can do stuff like this

select server_name from status where dayofweek(current_timestamp)=1
if(rc_ok) goto Sunday
select server_name from status where dayofweek(current_timestamp)=2
if(rc_ok) goto Monday
select server_name from status where dayofweek(current_timestamp)=3
if(rc_ok) goto Tuesday
...
etc etc etc
select server_name from status where dayofweek(current_timestamp)=7
if(rc_ok) goto Saturday
/* technically next line not needed but ... */
goto Exit
Monday:
....
goto Exit
Tuesday:
...
goto Exit

etc etc etc
Exit:
exit

I like to use constructs like this to get windows within a day
select server_name from status where hour(current_time) not in (12,13,14,15)
if(rc_notfound) goto exit
...

or to check if a process is already running before starting
select * from processes where process='Reclaim Storage Pool' and status like '%TAPEPOOL%'
if(rc_notfound) backup stg mesgdisk mesgcopy maxpr=$1

I don't have any docs or links though, just trial and error. And they can get pretty ugly so moderation is the key. And you might want to use calls to scripts using the run command to keep any single script reasonable to read.
 
Great example rmazzon - Thanks!

In reading about the IF in TSM, it does look to be really limited. :( That really hurts my feelings coming from AIX/kornshell scripting.

The extra examples are also appreciated. My previous script for starting reclamation would get the current time and do a simple subtraction to give "recl stg" a duration. But with the example you gave to see if a process is running, I'll just schedule the reclamation to start, have it check for processes which _should_ be finished (like stg pool backups or DB backups) and run for a predetermined amount of time.

Off to experiment!

Thanks again,
TMan
 
Back
Top