Been looking to do some cleanup and I wanted an easy way to do it. So...I wrote this script. I can take the list returned and either make it a macro or an internal TSM script. Sure I could build a shell script that processed a list with the TSM server_name, the node_name, and FSID but I thought I'd show how you can create a command out of SQL returned data.
select 'del filespace ' || node_name || ' ' || cast(FILESPACE_ID as char(3)) || ' type=backup nametype=fsid wait=yes' AS COMMAND from filespaces where cast((current_timestamp-backup_end)days as decimal)>90
Here is an example of the results from the script:
COMMAND
------------------------------------------------------------
del filespace NODE1 37 type=backup nametype=fsid wait=yes
del filespace NODE1 9 type=backup nametype=fsid wait=yes
del filespace NODE1 36 type=backup nametype=fsid wait=yes
del filespace NEO_1 32 type=backup nametype=fsid wait=yes
del filespace NEO_1 31 type=backup nametype=fsid wait=yes
del filespace NEO_1 23 type=backup nametype=fsid wait=yes
del filespace NEO_1 29 type=backup nametype=fsid wait=yes
Chad,
ReplyDeleteCan you give me a scenario where you would have a need to clean up filespaces like this? Some sort of database backups? I haven't (yet) run across a need to do something like this, so I'm curious.
Thanks!
Tom
Typically I use this when decommed servers have gone past the stated retention time and we are allowed to delete their data. I've work on some accounts where we had to provide the documentation (actlog records) that the data was removed. So I would run this as a script. I had to provide a Q FILESpace for the node, the script name, the commands it ran, and the resulting actlog info in the ticket closure.
ReplyDeleteChad,
ReplyDeleteThanks, I have been looking for something like this. Does your script take input from command line, specifically the host/client name ?
You can pass items to the script using the variable option.
ReplyDeleteExample:
run del_fs NODE1
select 'del filespace ' || node_name || ' ' || cast(FILESPACE_ID as char(3)) || ' type=backup nametype=fsid wait=yes' AS COMMAND from filespaces where cast((current_timestamp-backup_end)days as decimal)>90 and node_name='$1'
COMMAND
------------------------------------------------------------
del filespace NODE1 37 type=backup nametype=fsid wait=yes
del filespace NODE1 9 type=backup nametype=fsid wait=yes
del filespace NODE1 36 type=backup nametype=fsid wait=yes
Great! thank you. Once more question, I am actually interested in a shell script. So can I assume I can do something like this.
ReplyDelete1. script name del_fs
2. dsmadmc -id=xx -pass=xx "select 'del filespace ' || node_name || ' ' || cast(FILESPACE_ID as char(3)) || ' type=backup nametype=fsid wait=yes' AS COMMAND from filespaces where cast((current_timestamp-backup_end)days as decimal)>90 and node_name='$1'"
3. so then basically I can run ./del_fs NODE1 and it would delete ALL instances of the filespace using FSID #
I am intersted in deleting ALL instances of the filespace and the node itself.
Thank you so much.
This comment has been removed by the author.
ReplyDeleteIf you do the following it makes it easier to reuse over and over again.
ReplyDeleteOn the TSM server save the following as a script called del_fs
def script del_fs desc="Will create a list of filespaces that can be deleted due to being inactive for over 90 days"
upd script del_fs "select 'del filespace ' || node_name || ' ' || cast(FILESPACE_ID as char(3)) || ' -"
upd script del_fs "type=backup nametype=fsid wait=yes' AS COMMAND from filespaces where -"
upd script del_fs "cast((current_timestamp-backup_end)days as decimal)>90 and node_name='$1' "
#!/bin/ksh
ID=`cat /usr/tivoli/tsm/client/ba/bin/VARS/ADSMID`
PA=`cat /usr/tivoli/tsm/client/ba/bin/VARS/ADSMPA`
clear
echo "Enter the node to process: \c"
read NODE
dsmadmc -id=xx -pass=xx -dataonly=yes -commadelimited -outfile=./tmp.txt run del_fs $NODE
while read LINE
do
dsmadmc -id=xx -pass=xx $LINE
done < tmp.txt
Thank you for the script. One more question, how do you create a custom script on the server, sorry total newbie with not proper training. I did look on the TSM ISC but it looked like it wanted me to pick a specific task. Furthermore, I would prefer to use the command line. If you could show me how to create the custom script within TSM that would be fantastic.
ReplyDeleteThank you so much.
When I run the SQL statement, the filespaces aren't deleted--all it does it output the "del filspace..." text. How do you get it to actually execute the delete commands?
ReplyDeleteI usually don't automate deletions. I run the report and double check my results then run the macro through a different script. You can send the output to a file and run the file as a macro from the TSM admin command line. Pretty easy to do if you know shell scripting.
ReplyDelete