home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Backup / Backup.zip / dtsaver.zip / dtsaver.cmd < prev   
OS/2 REXX Batch file  |  2000-02-06  |  3KB  |  116 lines

  1. /*  DTSaver.cmd
  2. Save OS/2 ini files and the Config.sys
  3.  
  4. Marko Zarkovic, February 2000
  5. Ottawa, Canada
  6.  
  7. */
  8.  
  9.  
  10.  
  11. /*variables to set 
  12. ####################################*/
  13.  
  14. BUval = 20 /*number of files to save before cleaning up*/
  15. CUval = 5 /*number of files to delete*/
  16.  
  17. /*
  18. ####################################*/
  19.  
  20.  
  21.  
  22. '@echo off'
  23. parse arg hostdrive
  24. /* hostdrive is the drive letter and colon
  25. should be set up as a parameter in a shadow */
  26.  
  27. call RxFuncAdd 'SysFileTree', 'RexxUtil', 'SysFileTree'
  28. call RxFuncAdd 'SysSleep', 'RexxUtil', 'SysSleep'
  29.  
  30. Tval=1 /*debug only*/
  31. budir = 'DESKTOP.BU'
  32. fname = budir ||'\' || date('B')
  33. list = hostdrive||'\os2\os2.ini' hostdrive||'\os2\os2sys.ini' hostdrive||'\config.sys'
  34. dt = hostdrive||'\Desktop'
  35.  
  36. /*main ++++++++++++++++++++++++++++++++++++++*/
  37. st=time()
  38. MD 'DESKTOP.BU'  /* this fails if the folder already exists */
  39. Say "Calling Zip..."
  40. call zipcall
  41. call inireport
  42. call MAINTENANCE
  43. say "Done!"
  44. et=time()
  45. say "dtsaver started at >>>" st "; ended at >>>" et
  46. call SysSleep 3
  47. beep(150,100)
  48. beep(300,100)
  49. beep(600,100)
  50. exit
  51.  
  52.  
  53. /*###############################################
  54. */
  55.  
  56. /*zipcall*/
  57. zipcall:
  58. c=0
  59. UID = 0 /*unique identifier*/
  60. do while UID = 0
  61.  tempname = fname||c
  62.  rc=SysFileTree(tempname||'.zip', fstr, F)
  63.  if fstr.0 > 0 then do /*if there is already a file so named*/
  64.   c=c+1  
  65.  end
  66.  else do
  67.   UID = 1
  68.  end
  69. end
  70. ZIP '-9S' tempname list
  71. ZIP '-r9S' tempname dt
  72. return
  73.  
  74. /*inireport*/
  75. inireport:
  76. repfile = 'ini_rprt.txt'
  77. os2ini = hostdrive||'\os2\os2.ini'
  78. sysini = hostdrive||'\os2\os2sys.ini'
  79. config = hostdrive||'\config.sys'
  80.  
  81. call SysFileTree os2ini, os2inistem, 'F'
  82. parse var os2inistem.1 fdate ftime fsize fatt fpath
  83. /* MUST use the rc= with lineout to catch the return value */
  84. rc = lineout(repfile,date() '['||time()||']' '->' fpath '-' fsize '-' fdate '-' ftime)
  85.  
  86. call SysFileTree sysini, sysinistem, 'F'
  87. parse var sysinistem.1 fdate ftime fsize fatt fpath
  88. rc = lineout(repfile,date() '['||time()||']' '->' fpath '-' fsize '-' fdate '-' ftime)
  89.  
  90. call SysFileTree config, configstem, 'F'
  91. parse var configstem.1 fdate ftime fsize fatt fpath
  92. rc = lineout(repfile,date() '['||time()||']' '-> ' config '-' fsize '-' fdate '-' ftime)
  93.  
  94. rc = lineout(repfile,'###################')
  95.  
  96. return
  97.  
  98. /*###############################################
  99. */
  100.  
  101. /* MAINTENANCE */
  102. MAINTENANCE:
  103. say "Checking the number of backups."
  104. call SysFileTree '.\'||budir||'\*', 'ffiles', 'F'
  105. say "There are " || ffiles.0 || " files."
  106. if ffiles.0>=BUval then do
  107.  DIR budir '/f /o:d > dirlist'
  108.  do i=1 to CUval
  109.   inline=linein('dirlist')
  110.   say 'Deleting' inline
  111.   DEL inline
  112.  end
  113. end
  114. return
  115.  
  116.