0 byte detection on dsmc backups

nextreme

Active Newcomer
Joined
Jun 9, 2012
Messages
10
Reaction score
0
Points
0
Our management just gave us a new direction on supporting 0byte file backups...We're supposed to find all files backed up by the client and report them to the user to see if we should back them up or delete them off the tsm server. I'm a hardcore unix guy, and this would not be an issue, however, i have to do it on windows (xp to win7). Do you guys have any ideas using windows powershell or a .bat script to do this?

inside of unix i would do something like this...

/bin/sh

CMD=${DSMCPATH}dsmc q backup | grep 0 bytes # very basic i know, just getting the point across
for x in ${CMD}
do
echo "FILE ${X} is 0 bytes" | tee -a ${OUTPUT}
done

mailx -s "file - 0 bytes" [email protected] < ${OUTPUT}


Any ideas? I have never written a script in windows and have no clue...
 
One way, and my lazy easy way out (no pun intended!):

The Unix equivalent commands like grep, tail, etc can be used in Windows DOS scripts. These utilities have been ported for DOS use, and writing scripts similar to how Unix behaves in DOS is possible.

Here is a link that has Unix commands for DOS: http://www.cyberciti.biz/faq/unix-command-line-utilities-for-windows/
 
I forgot to mention that this is on a government system, and cannot use anything like what was mentioned above...good old fashioned windows scripting is the only thing that I can use.

Would TSM reporter have any of those features available?
 
Would TSM reporter have any of those features available?

If you mean TSM OR (Operational Reporting) - not by default. You have to write one and it would not be easy. As you know OR is truly for the TSM server side reporting. Getting so info from the clients would require some skillful scripting and a lot of cross platform communication.

In short, not worth your while to look at OR.

You can use plain DOS scripts or Powershell.
 
Hi,

although it is not widely known, Windows system have equivalent of grep - it is called "findstr" - see "findstr /?" for details.
You can start with this:
Code:
dsmc q ba * -sub=yes | findstr /C:" 0  B"

Harry
 
So here's the script, and it works on the command line, but it's horked in a .bat script. Any ideas? The issue is when I try and parse the dsmc output...

@echo off
SET CURRENTTIME=%TIME%
IF "%CURRENTTIME:~0,1%"==" " (SET CURRENTTIME=0%CURRENTTIME:~1%)
FOR /F "tokens=2-4 delims=/ " %%A IN ('DATE /T') DO (SET TIMESTAMP=%%C-%%A-%%B %CURRENTTIME%)
echo %CURRENTTIME%

set OUTPUT=F:\FILES\0byteOUTPUT_%CURRENTTIME%.txt

F:

cd \"Program Files"\Tivoli\TSM\baclient\

dsmc q backup f:\* -subdir=yes '| findstr /C:" 0 B" > \FILES\0byteOUTPUT_%CURRENTTIME%.txt'

cd \FILES
 
So here's the script, and it works on the command line, but it's horked in a .bat script. Any ideas? The issue is when I try and parse the dsmc output...

@echo off
SET CURRENTTIME=%TIME%
IF "%CURRENTTIME:~0,1%"==" " (SET CURRENTTIME=0%CURRENTTIME:~1%)
FOR /F "tokens=2-4 delims=/ " %%A IN ('DATE /T') DO (SET TIMESTAMP=%%C-%%A-%%B %CURRENTTIME%)
echo %CURRENTTIME%

set OUTPUT=F:\FILES\0byteOUTPUT_%CURRENTTIME%.txt

F:

cd \"Program Files"\Tivoli\TSM\baclient\

dsmc q backup f:\* -subdir=yes | findstr /C:" 0 B" > \FILES\0byteOUTPUT_%CURRENTTIME%.txt

cd \FILES

Here's the output...

F:\FILES>0byte.bat
08:31:02.18
The filename, directory name, or volume label syntax is incorrect.
 
Try this:

F:
cd \"Program Files"\Tivoli\TSM\baclient\ ***I presume this directory is in F: rather than C:? ***
dsmc q backup f:\* -subdir=yes | findstr /C:" 0 B" >> F:\FILES\0byteOUTPUT_%CURRENTTIME%.txt
cd F:\FILES
 
because of the different client versions, i have to make it work w/5.5 first, then upgrade it to 6.3 (client). So I installed the client of 5.5 to F:\blah...

With the redirection, i'm still hitting the error.


Try this:

F:
cd \"Program Files"\Tivoli\TSM\baclient\ ***I presume this directory is in F: rather than C:? ***
dsmc q backup f:\* -subdir=yes | findstr /C:" 0 B" >> F:\FILES\0byteOUTPUT_%CURRENTTIME%.txt
cd F:\FILES
 
Hi,

this works for me
Code:
@echo off
For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c-%%a-%%b)
For /f "tokens=1-2 delims=/:" %%a in ("%TIME%") do (set mytime=%%a%%b)
echo %mydate%_%mytime%

set OUTPUT=c:\0byteOUTPUT_%mydate%_%mytime%.txt
cd \"Program Files"\Tivoli\TSM\baclient\
dsmc q ba * -sub=yes | findstr /C:" 0  B" > %OUTPUT%
cd \

note that there are two spaces between "0" and "B" in the "findstr" command

Harry
 
Finally got it:

First script calls the second script:

Here's the run me script:
=======================================================================

@echo off

set HOST=%ComputerName%


:: Datestamp (8 digets)
for /f "tokens=2-4 skip=1 delims=(-./)" %%i in ('echo.^|date') do (
for /f "tokens=1-4 delims=-./ " %%m in ('date /t') do (
(set dow=%%m)&(set %%i=%%n)&(set %%j=%%o)&(set yyyy=%%p)))
Set "mydate=%yyyy%_%mm%_%dd%"


echo ###################################### > F:\FILES\OUTPUT\output_for_0byte_%HOST%_%mydate%.txt
echo # Start of Collection for %HOST% >> F:\FILES\OUTPUT\output_for_0byte_%HOST%_%mydate%.txt
echo ###################################### >> F:\FILES\OUTPUT\output_for_0byte_%HOST%_%mydate%.txt

echo\ >> F:\FILES\OUTPUT\output_for_0byte_%HOST%_%mydate%.txt
echo Script ran on %mydate% >> F:\FILES\OUTPUT\output_for_0byte_%HOST%_%mydate%.txt
echo\ >> F:\FILES\OUTPUT\output_for_0byte_%HOST%_%mydate%.txt

f:\FILES\0byte.bat >> F:\FILES\OUTPUT\output_for_0byte_%HOST%_%mydate%.txt

=======================================================================

Here's the 0byte.bat script

=======================================================================
@echo off
SET CURRENTTIME=%TIME%
IF "%CURRENTTIME:~0,1%"==" " (SET CURRENTTIME=0%CURRENTTIME:~1%)
FOR /F "tokens=2-4 delims=/ " %%A IN ('DATE /T') DO (SET TIMESTAMP=%%C-%%A-%%B %CURRENTTIME%)

echo %CURRENTTIME%

set OUTPUT=F:\FILES\OUTPUT_%CURRENTTIME%.txt

F:

cd \"Program Files"\Tivoli\TSM\baclient
dsmc q backup f:\* -subdir=yes | findstr /C:" 0 B"


cd \FILES

=======================================================================


Now all i have to do is write a perl roll up script...will post that also when i'm done...
 
Back
Top