1. Forum Rules (PLEASE CLICK HERE TO READ BEFORE POSTING) Click the link to access ADSM.ORG Acceptable Use Policy and forum rules which should be observed when using this website. Violators may be banned from this website. This message will disappear after you have made at least 12 posts. Thank you for your cooperation.

0 byte detection on dsmc backups

Discussion in 'Scripting' started by nextreme, Jun 9, 2012.

  1. nextreme

    nextreme New Member

    Joined:
    Jun 9, 2012
    Messages:
    10
    Likes Received:
    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" tsmadmin@adsm.org < ${OUTPUT}


    Any ideas? I have never written a script in windows and have no clue...
     
  2.  
  3. moon-buddy

    moon-buddy Moderator

    Joined:
    Aug 24, 2005
    Messages:
    6,114
    Likes Received:
    273
    Occupation:
    Electronics Engineer, Security Professional
    Location:
    Somewhere in the US
    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/
     
  4. nextreme

    nextreme New Member

    Joined:
    Jun 9, 2012
    Messages:
    10
    Likes Received:
    0
    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?
     
  5. moon-buddy

    moon-buddy Moderator

    Joined:
    Aug 24, 2005
    Messages:
    6,114
    Likes Received:
    273
    Occupation:
    Electronics Engineer, Security Professional
    Location:
    Somewhere in the US
    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.
     
  6. Harry_Redl

    Harry_Redl Moderator

    Joined:
    Dec 29, 2003
    Messages:
    2,258
    Likes Received:
    134
    Occupation:
    IT Consultant
    Location:
    Czech Republic
    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
     
  7. nextreme

    nextreme New Member

    Joined:
    Jun 9, 2012
    Messages:
    10
    Likes Received:
    0
    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
     
  8. nextreme

    nextreme New Member

    Joined:
    Jun 9, 2012
    Messages:
    10
    Likes Received:
    0
    Here's the output...

    F:\FILES>0byte.bat
    08:31:02.18
    The filename, directory name, or volume label syntax is incorrect.
     
  9. moon-buddy

    moon-buddy Moderator

    Joined:
    Aug 24, 2005
    Messages:
    6,114
    Likes Received:
    273
    Occupation:
    Electronics Engineer, Security Professional
    Location:
    Somewhere in the US
    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
     
  10. nextreme

    nextreme New Member

    Joined:
    Jun 9, 2012
    Messages:
    10
    Likes Received:
    0
    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.


     
  11. moon-buddy

    moon-buddy Moderator

    Joined:
    Aug 24, 2005
    Messages:
    6,114
    Likes Received:
    273
    Occupation:
    Electronics Engineer, Security Professional
    Location:
    Somewhere in the US
    Change %CURRENTTIME% to %TIME%
     
  12. Harry_Redl

    Harry_Redl Moderator

    Joined:
    Dec 29, 2003
    Messages:
    2,258
    Likes Received:
    134
    Occupation:
    IT Consultant
    Location:
    Czech Republic
    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
     
  13. nextreme

    nextreme New Member

    Joined:
    Jun 9, 2012
    Messages:
    10
    Likes Received:
    0
    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...
     

Share This Page