Link to home
Start Free TrialLog in
Avatar of aquavita
aquavita

asked on

Scheduled task did not run...not clear as to why

I have scripts that are set to run on a day to day basis...and today i discovered that this script has not run on friday since the 6th. Yet the same script has been running every other day with no issues. I tried looking in the event log with no luck, and the SchedLgU.Txt file has this output...

"At1.job" (SAVFMSELive.exe) 10/21/2006 2:00:01 PM ** ERROR **
      Unable to start task.
      The specific error is:
      0x80070005: Access is denied.
      Try using the Task page Browse button to locate the application.
"At14.job" (SAVFMSELive.exe)
      Started 10/21/2006 2:14:00 PM
"At14.job" (SAVFMSELive.exe)
      Finished 10/21/2006 2:15:08 PM
      Result: The task completed with an exit code of (0).
"At15.job" (SAVFMSELive.exe)
      Started 10/21/2006 3:14:00 PM
"At15.job" (SAVFMSELive.exe)
      Finished 10/21/2006 3:15:40 PM
      Result: The task completed with an exit code of (0).
"At16.job" (SAVFMSELive.exe)
      Started 10/21/2006 4:14:00 PM
"At16.job" (SAVFMSELive.exe)
      Finished 10/21/2006 4:15:09 PM
      Result: The task completed with an exit code of (0).
"At17.job" (SAVFMSELive.exe)
      Started 10/21/2006 5:14:00 PM
"At17.job" (SAVFMSELive.exe)
      Finished 10/21/2006 5:15:04 PM
      Result: The task completed with an exit code of (0).
"At18.job" (SAVFMSELive.exe)
      Started 10/21/2006 6:14:00 PM
"At18.job" (SAVFMSELive.exe)
      Finished 10/21/2006 6:20:19 PM
      Result: The task completed with an exit code of (0).
"At19.job" (SAVFMSELive.exe)
      Started 10/21/2006 7:14:00 PM
"At19.job" (SAVFMSELive.exe)
      Finished 10/21/2006 7:15:08 PM
      Result: The task completed with an exit code of (0).
"At20.job" (SAVFMSELive.exe)
      Started 10/21/2006 8:14:00 PM
"At20.job" (SAVFMSELive.exe)
      Finished 10/21/2006 8:23:46 PM
      Result: The task completed with an exit code of (0).
"_ExchSys.job" (Exch-SysBkup.bat)
      Started 10/21/2006 9:05:00 PM
"At21.job" (SAVFMSELive.exe)
      Started 10/21/2006 9:14:01 PM
"At21.job" (SAVFMSELive.exe)
      Finished 10/21/2006 9:19:06 PM
      Result: The task completed with an exit code of (0).
"_ExchSys.job" (Exch-SysBkup.bat)
      Finished 10/21/2006 9:33:27 PM
      Result: The task completed with an exit code of (0).
"At22.job" (SAVFMSELive.exe)
      Started 10/21/2006 10:14:00 PM
"At22.job" (SAVFMSELive.exe)
      Finished 10/21/2006 10:15:04 PM
      Result: The task completed with an exit code of (0).
"At23.job" (SAVFMSELive.exe)
      Started 10/21/2006 11:14:00 PM
"At23.job" (SAVFMSELive.exe)
      Finished 10/21/2006 11:26:44 PM
      Result: The task completed with an exit code of (0).
"At24.job" (SAVFMSELive.exe)
      Started 10/22/2006 12:14:00 AM
"At24.job" (SAVFMSELive.exe)
      Finished 10/22/2006 12:15:07 AM
      Result: The task completed with an exit code of (0).
"IsaDailySummary.job" (DAILYSUM.EXE)
      Started 10/22/2006 12:30:00 AM
"IsaDailySummary.job" (DAILYSUM.EXE)
      Finished 10/22/2006 12:30:01 AM
      Result: The task completed with an exit code of (0).
"At25.job" (SAVFMSELive.exe)
      Started 10/22/2006 1:14:00 AM
"At25.job" (SAVFMSELive.exe)
      Finished 10/22/2006 1:19:56 AM
      Result: The task completed with an exit code of (0).
"At26.job" (SAVFMSELive.exe)
      Started 10/22/2006 2:14:00 AM
"At26.job" (SAVFMSELive.exe)
      Finished 10/22/2006 2:15:10 AM
      Result: The task completed with an exit code of (0).
"At3.job" (SAVFMSELive.exe)
      Started 10/22/2006 3:14:00 AM
"At3.job" (SAVFMSELive.exe)
      Finished 10/22/2006 3:22:31 AM
      Result: The task completed with an exit code of (0).
"At4.job" (SAVFMSELive.exe)
      Started 10/22/2006 4:14:00 AM
"At4.job" (SAVFMSELive.exe)
      Finished 10/22/2006 4:41:42 AM
      Result: The task completed with an exit code of (0).
"At5.job" (SAVFMSELive.exe)
      Started 10/22/2006 5:14:00 AM
"At5.job" (SAVFMSELive.exe)
      Finished 10/22/2006 5:15:13 AM
      Result: The task completed with an exit code of (0).
"At6.job" (SAVFMSELive.exe)
      Started 10/22/2006 6:14:00 AM
"At6.job" (SAVFMSELive.exe)
      Finished 10/22/2006 6:19:32 AM
      Result: The task completed with an exit code of (0).
"At7.job" (SAVFMSELive.exe)
      Started 10/22/2006 7:14:00 AM
"At7.job" (SAVFMSELive.exe)
      Finished 10/22/2006 7:19:13 AM
      Result: The task completed with an exit code of (0).
"At8.job" (SAVFMSELive.exe)
      Started 10/22/2006 8:14:00 AM
"At8.job" (SAVFMSELive.exe)
      Finished 10/22/2006 8:19:54 AM
      Result: The task completed with an exit code of (0).
"At9.job" (SAVFMSELive.exe)
      Started 10/22/2006 9:14:00 AM
"At9.job" (SAVFMSELive.exe)
      Finished 10/22/2006 9:15:08 AM
      Result: The task completed with an exit code of (0).
"At10.job" (SAVFMSELive.exe)
      Started 10/22/2006 10:14:00 AM
"At10.job" (SAVFMSELive.exe)
      Finished 10/22/2006 10:15:38 AM
      Result: The task completed with an exit code of (0).
"At11.job" (SAVFMSELive.exe)
      Started 10/22/2006 11:14:00 AM
"At11.job" (SAVFMSELive.exe)
      Finished 10/22/2006 11:15:05 AM
      Result: The task completed with an exit code of (0).
"At12.job" (SAVFMSELive.exe)
      Started 10/22/2006 12:14:00 PM
"At12.job" (SAVFMSELive.exe)
      Finished 10/22/2006 12:24:55 PM
      Result: The task completed with an exit code of (0).
"At13.job" (SAVFMSELive.exe)
      Started 10/22/2006 1:14:00 PM
"At13.job" (SAVFMSELive.exe)
      Finished 10/22/2006 1:15:06 PM
      Result: The task completed with an exit code of (0).
"At1.job" (SAVFMSELive.exe) 10/22/2006 2:00:02 PM ** ERROR **
      Unable to start task.
      The specific error is:
      0x80070005: Access is denied.
      Try using the Task page Browse button to locate the application.
"At14.job" (SAVFMSELive.exe)
      Started 10/22/2006 2:14:00 PM
"At14.job" (SAVFMSELive.exe)
      Finished 10/22/2006 2:20:51 PM
      Result: The task completed with an exit code of (0).
"At15.job" (SAVFMSELive.exe)
      Started 10/22/2006 3:14:00 PM
"At15.job" (SAVFMSELive.exe)
      Finished 10/22/2006 3:22:24 PM
      Result: The task completed with an exit code of (0).
"At16.job" (SAVFMSELive.exe)
      Started 10/22/2006 4:14:00 PM
"At16.job" (SAVFMSELive.exe)
      Finished 10/22/2006 4:15:02 PM
      Result: The task completed with an exit code of (0).
"At17.job" (SAVFMSELive.exe)
      Started 10/22/2006 5:14:00 PM
"At17.job" (SAVFMSELive.exe)
      Finished 10/22/2006 5:23:09 PM
      Result: The task completed with an exit code of (0).
"At18.job" (SAVFMSELive.exe)
      Started 10/22/2006 6:14:00 PM
"At18.job" (SAVFMSELive.exe)
      Finished 10/22/2006 6:20:05 PM
      Result: The task completed with an exit code of (0).
"At19.job" (SAVFMSELive.exe)
      Started 10/22/2006 7:14:00 PM
"At19.job" (SAVFMSELive.exe)
      Finished 10/22/2006 7:20:52 PM
      Result: The task completed with an exit code of (0).
"At20.job" (SAVFMSELive.exe)
      Started 10/22/2006 8:14:00 PM
"At20.job" (SAVFMSELive.exe)
      Finished 10/22/2006 8:15:04 PM
      Result: The task completed with an exit code of (0).
"_ExchSys.job" (Exch-SysBkup.bat)
      Started 10/22/2006 9:05:00 PM
"At21.job" (SAVFMSELive.exe)
      Started 10/22/2006 9:14:00 PM
"At21.job" (SAVFMSELive.exe)
      Finished 10/22/2006 9:20:23 PM
      Result: The task completed with an exit code of (0).
"_ExchSys.job" (Exch-SysBkup.bat)
      Finished 10/22/2006 9:34:32 PM
      Result: The task completed with an exit code of (0).
"At22.job" (SAVFMSELive.exe)
      Started 10/22/2006 10:14:00 PM
"At22.job" (SAVFMSELive.exe)
      Finished 10/22/2006 10:25:33 PM
      Result: The task completed with an exit code of (0).
"At23.job" (SAVFMSELive.exe)
      Started 10/22/2006 11:14:00 PM
"At23.job" (SAVFMSELive.exe)
      Finished 10/22/2006 11:23:51 PM
      Result: The task completed with an exit code of (0).
"At24.job" (SAVFMSELive.exe)
      Started 10/23/2006 12:14:00 AM
"At24.job" (SAVFMSELive.exe)
      Finished 10/23/2006 12:15:41 AM
      Result: The task completed with an exit code of (0).
"IsaDailySummary.job" (DAILYSUM.EXE)
      Started 10/23/2006 12:30:00 AM
"_DailyMirrored.job" (DailyMirrored.bat)
      Started 10/23/2006 12:30:01 AM
"IsaDailySummary.job" (DAILYSUM.EXE)
      Finished 10/23/2006 12:30:04 AM
      Result: The task completed with an exit code of (0).
"_DailyMirrored.job" (DailyMirrored.bat)
      Finished 10/23/2006 12:34:08 AM
      Result: The task completed with an exit code of (0).
"At25.job" (SAVFMSELive.exe)
      Started 10/23/2006 1:14:00 AM
"At25.job" (SAVFMSELive.exe)
      Finished 10/23/2006 1:23:33 AM
      Result: The task completed with an exit code of (0).
"At26.job" (SAVFMSELive.exe)
      Started 10/23/2006 2:14:00 AM
"At26.job" (SAVFMSELive.exe)
      Finished 10/23/2006 2:15:12 AM
      Result: The task completed with an exit code of (0).
"At3.job" (SAVFMSELive.exe)
      Started 10/23/2006 3:14:00 AM
"At3.job" (SAVFMSELive.exe)
      Finished 10/23/2006 3:20:50 AM
      Result: The task completed with an exit code of (0).
"At4.job" (SAVFMSELive.exe)
      Started 10/23/2006 4:14:01 AM
"At4.job" (SAVFMSELive.exe)
      Finished 10/23/2006 4:55:37 AM
      Result: The task completed with an exit code of (123).
"At5.job" (SAVFMSELive.exe)
      Started 10/23/2006 5:14:00 AM
"At5.job" (SAVFMSELive.exe)
      Finished 10/23/2006 5:45:49 AM
      Result: The task completed with an exit code of (0).
"At6.job" (SAVFMSELive.exe)
      Started 10/23/2006 6:14:00 AM
"At6.job" (SAVFMSELive.exe)
      Finished 10/23/2006 6:55:36 AM
      Result: The task completed with an exit code of (0).
"ShadowCopyVolume{0c3f695d-9509-11d8-9264-806d6172696f}.job" (vssadmin.exe)
      Started 10/23/2006 7:00:00 AM
"ShadowCopyVolume{0c3f695d-9509-11d8-9264-806d6172696f}.job" (vssadmin.exe)
      Finished 10/23/2006 7:00:09 AM
      Result: The task completed with an exit code of (0).
"At7.job" (SAVFMSELive.exe)
      Started 10/23/2006 7:14:00 AM
"At7.job" (SAVFMSELive.exe)
      Finished 10/23/2006 7:22:24 AM
      Result: The task completed with an exit code of (0).
"At8.job" (SAVFMSELive.exe)
      Started 10/23/2006 8:14:00 AM
"At8.job" (SAVFMSELive.exe)
      Finished 10/23/2006 8:15:20 AM
      Result: The task completed with an exit code of (0).
[ ***** Most recent entry is above this line ***** ]

     
"ShadowCopyVolume{0c3f695d-9509-11d8-9264-806d6172696f}.job" (vssadmin.exe)
      Finished 10/20/2006 7:00:06 AM
      Result: The task completed with an exit code of (0).
"At7.job" (SAVFMSELive.exe)
      Started 10/20/2006 7:14:00 AM
"At7.job" (SAVFMSELive.exe)
      Finished 10/20/2006 7:21:10 AM
      Result: The task completed with an exit code of (0).
"At8.job" (SAVFMSELive.exe)
      Started 10/20/2006 8:14:00 AM
"At8.job" (SAVFMSELive.exe)
      Finished 10/20/2006 8:15:16 AM
      Result: The task completed with an exit code of (0).
"At9.job" (SAVFMSELive.exe)
      Started 10/20/2006 9:14:00 AM
"At9.job" (SAVFMSELive.exe)
      Finished 10/20/2006 9:22:48 AM
      Result: The task completed with an exit code of (0).
"At10.job" (SAVFMSELive.exe)
      Started 10/20/2006 10:14:00 AM
"At10.job" (SAVFMSELive.exe)
      Finished 10/20/2006 10:15:51 AM
      Result: The task completed with an exit code of (0).
"At11.job" (SAVFMSELive.exe)
      Started 10/20/2006 11:14:00 AM
"At11.job" (SAVFMSELive.exe)
      Finished 10/20/2006 11:25:24 AM
      Result: The task completed with an exit code of (0).
"ShadowCopyVolume{0c3f695d-9509-11d8-9264-806d6172696f}.job" (vssadmin.exe)
      Started 10/20/2006 12:00:00 PM
"ShadowCopyVolume{0c3f695d-9509-11d8-9264-806d6172696f}.job" (vssadmin.exe)
      Finished 10/20/2006 12:00:06 PM
      Result: The task completed with an exit code of (0).
"At12.job" (SAVFMSELive.exe)
      Started 10/20/2006 12:14:00 PM
"At12.job" (SAVFMSELive.exe)
      Finished 10/20/2006 12:16:27 PM
      Result: The task completed with an exit code of (0).
"At13.job" (SAVFMSELive.exe)
      Started 10/20/2006 1:14:00 PM
"At13.job" (SAVFMSELive.exe)
      Finished 10/20/2006 1:17:08 PM
      Result: The task completed with an exit code of (0).
"At1.job" (SAVFMSELive.exe) 10/20/2006 2:00:03 PM ** ERROR **
      Unable to start task.
      The specific error is:
      0x80070005: Access is denied.
      Try using the Task page Browse button to locate the application.
"At14.job" (SAVFMSELive.exe)
      Started 10/20/2006 2:14:00 PM
"At14.job" (SAVFMSELive.exe)
      Finished 10/20/2006 2:20:33 PM
      Result: The task completed with an exit code of (0).
"At15.job" (SAVFMSELive.exe)
      Started 10/20/2006 3:14:00 PM
"At15.job" (SAVFMSELive.exe)
      Finished 10/20/2006 3:16:03 PM
      Result: The task completed with an exit code of (0).
"At16.job" (SAVFMSELive.exe)
      Started 10/20/2006 4:14:00 PM
"At16.job" (SAVFMSELive.exe)
      Finished 10/20/2006 4:27:40 PM
      Result: The task completed with an exit code of (0).
"At17.job" (SAVFMSELive.exe)
      Started 10/20/2006 5:14:00 PM
"At17.job" (SAVFMSELive.exe)
      Finished 10/20/2006 5:21:27 PM
      Result: The task completed with an exit code of (0).
"At18.job" (SAVFMSELive.exe)
      Started 10/20/2006 6:14:00 PM
"At18.job" (SAVFMSELive.exe)
      Finished 10/20/2006 6:15:55 PM
      Result: The task completed with an exit code of (0).
"At19.job" (SAVFMSELive.exe)
      Started 10/20/2006 7:14:00 PM
"At19.job" (SAVFMSELive.exe)
      Finished 10/20/2006 7:21:27 PM
      Result: The task completed with an exit code of (0).
"At20.job" (SAVFMSELive.exe)
      Started 10/20/2006 8:14:00 PM
"At20.job" (SAVFMSELive.exe)
      Finished 10/20/2006 8:22:13 PM
      Result: The task completed with an exit code of (0).
"_ExchSys.job" (Exch-SysBkup.bat)
      Started 10/20/2006 9:05:00 PM
"At21.job" (SAVFMSELive.exe)
      Started 10/20/2006 9:14:00 PM
"At21.job" (SAVFMSELive.exe)
      Finished 10/20/2006 9:23:30 PM
      Result: The task completed with an exit code of (0).
"_ExchSys.job" (Exch-SysBkup.bat)
      Finished 10/20/2006 9:35:35 PM
      Result: The task completed with an exit code of (0).
"At22.job" (SAVFMSELive.exe)
      Started 10/20/2006 10:14:00 PM
"At22.job" (SAVFMSELive.exe)
      Finished 10/20/2006 10:22:04 PM
      Result: The task completed with an exit code of (0).
"At23.job" (SAVFMSELive.exe)
      Started 10/20/2006 11:14:00 PM
"At23.job" (SAVFMSELive.exe)
      Finished 10/20/2006 11:28:01 PM
      Result: The task completed with an exit code of (123).
"_DailyRolling.job" (DailyRolling.bat)
      Started 10/20/2006 11:30:00 PM
"_DailyRolling.job" (DailyRolling.bat)
      Finished 10/20/2006 11:30:00 PM
      Result: The task completed with an exit code of (ff).
"At24.job" (SAVFMSELive.exe)
      Started 10/21/2006 12:14:00 AM
"At24.job" (SAVFMSELive.exe)
      Finished 10/21/2006 12:15:05 AM
      Result: The task completed with an exit code of (0).
"IsaDailySummary.job" (DAILYSUM.EXE)
      Started 10/21/2006 12:30:00 AM
"IsaDailySummary.job" (DAILYSUM.EXE)
      Finished 10/21/2006 12:30:02 AM
      Result: The task completed with an exit code of (0).
"At25.job" (SAVFMSELive.exe)
      Started 10/21/2006 1:14:00 AM
"At25.job" (SAVFMSELive.exe)
      Finished 10/21/2006 1:15:09 AM
      Result: The task completed with an exit code of (0).
"At26.job" (SAVFMSELive.exe)
      Started 10/21/2006 2:14:00 AM
"At26.job" (SAVFMSELive.exe)
      Finished 10/21/2006 2:15:08 AM
      Result: The task completed with an exit code of (0).
"At3.job" (SAVFMSELive.exe)
      Started 10/21/2006 3:14:00 AM
"At3.job" (SAVFMSELive.exe)
      Finished 10/21/2006 3:15:19 AM
      Result: The task completed with an exit code of (0).
"At4.job" (SAVFMSELive.exe)
      Started 10/21/2006 4:14:01 AM
"At4.job" (SAVFMSELive.exe)
      Finished 10/21/2006 4:40:33 AM
      Result: The task completed with an exit code of (0).
"At5.job" (SAVFMSELive.exe)
      Started 10/21/2006 5:14:00 AM
"At5.job" (SAVFMSELive.exe)
      Finished 10/21/2006 5:15:09 AM
      Result: The task completed with an exit code of (0).
"At6.job" (SAVFMSELive.exe)
      Started 10/21/2006 6:14:00 AM
"At6.job" (SAVFMSELive.exe)
      Finished 10/21/2006 6:15:06 AM
      Result: The task completed with an exit code of (0).
"At7.job" (SAVFMSELive.exe)
      Started 10/21/2006 7:14:00 AM
"At7.job" (SAVFMSELive.exe)
      Finished 10/21/2006 7:22:27 AM
      Result: The task completed with an exit code of (0).
"At8.job" (SAVFMSELive.exe)
      Started 10/21/2006 8:14:00 AM
"At8.job" (SAVFMSELive.exe)
      Finished 10/21/2006 8:22:48 AM
      Result: The task completed with an exit code of (0).
"At9.job" (SAVFMSELive.exe)
      Started 10/21/2006 9:14:00 AM
"At9.job" (SAVFMSELive.exe)
      Finished 10/21/2006 9:15:04 AM
      Result: The task completed with an exit code of (0).
"At10.job" (SAVFMSELive.exe)
      Started 10/21/2006 10:14:00 AM
"At10.job" (SAVFMSELive.exe)
      Finished 10/21/2006 10:15:43 AM
      Result: The task completed with an exit code of (0).
"At11.job" (SAVFMSELive.exe)
      Started 10/21/2006 11:14:00 AM
"At11.job" (SAVFMSELive.exe)
      Finished 10/21/2006 11:21:33 AM
      Result: The task completed with an exit code of (0).
"At12.job" (SAVFMSELive.exe)
      Started 10/21/2006 12:14:00 PM
"At12.job" (SAVFMSELive.exe)
      Finished 10/21/2006 12:20:07 PM
      Result: The task completed with an exit code of (0).
"At13.job" (SAVFMSELive.exe)
      Started 10/21/2006 1:14:00 PM
"At13.job" (SAVFMSELive.exe)
      Finished 10/21/2006 1:15:39 PM
      Result: The task completed with an exit code of (0).
 

I inherited this mess and I'm trying to figure it out. This was an important script as it was performing backups. Any help would be very much appreciated. Again, it is supposed to run on fridays, but hasn't been since the 6th.

Avatar of Chris Staunton
Chris Staunton
Flag of United States of America image

Check the account information on the user that is running this task.  Did the account expire, did the password change?

Start there, I'm sure it will be an easy troubleshooting task.


Cheers,


Shoota
Avatar of aquavita
aquavita

ASKER

Well it's running as administrator...and the same task (dailyrolling.bat) runs fine every other day of the week but friday. THis is what I cannot figure out. It was a robocopy.bat generated batch file.
Well it's probably just erroring on the executable then.  Meaning that you can't back it up if it's working, you might want to exclude it from your backup rotation.

Cheers,

Shoota
I don't understand...it looks to me as though it's trying to RUN that exe, which apparently is a symantec mail center exe. How would that stop the entire backup?
maybe your robocopy settings stop the running backup if it encounters an open file?

Would be my only thought.


Shoota

WEll here is the script itself...I don't see anything that would cause this...

@echo off
::
:: Daily Rolling Backup of several directories to any number of available drives or mountpoints.
::
:: One umbrella folder 'Backup_XXX' is created as a backup folder.
:: Underneath, subfolders 'mirrored' and 'rolling' (only created if used).  
:: 'mirrored' contains only one copy of data, updated each time this backup is run for archived/install/etc. files.
:: 'rolling' has dated subfolders (new one each day) containing files that change creating a history of change.
:: When the drive becomes full, the oldest 'rolling' folders are deleted.
::
:: Uses inline procedures (call :label), so only available on 2000 server or better if extensions enabled.
:: Date and Time are already special environmental variables in Windows 2000
:: Use caret ^ before special characters like |, so it can be used in e.g.:   for /f ('xx ^| yy')
:: See SET command for %I:~x,y% string manipulations, FOR command for %~ expansions (can use in batch parms: %1, %2...)
:: Google "windows 2000 batch pipe"
:: -good info: //http://www.fpschultze.de/bss.htm  anything by Steve Hardy (NT/Win2K)


:: Method - Check each drive or mountpoint (folder) to find VerifyFile in its root directory.  VerifyFile
::          will contain one or more days of the week (one per line) to indicate the drive accepts backups
::          on those days. The first drive found with today's day (Mon, Tue, ...) will be used.
::
::          Rolling backups should include data files for which you want a history of backups.
::          Mirrored backups are those files you don't want to lose, but only need one copy per drive      
::          If there is less free space than 'MinSpace10MB' (# * 10MBs), delete up to 'DeleteMax' of oldest 'rolling'
::          backup folders. If unable to delete, exit.  Ideally, many drives are online for different days' backups.
::
::          This offers an advantage that a backup medium can be brought online to any available drive
::          letter or folder, and can be designated only to accept backup on certain days.
::          Make sure any 'catch-all' drive or folder is listed last.  It would have every day in its VerifyFile.


:: Cheat. This script calls itself later in a FOR /F to list the backup drives and again to list backup directories.
:: In this way, the backup batch script and the backup parms are both in one file and easy to manage.


::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: Check first argument, if '/list' echo directories and exit.  Source,Target,and Type separated by semi-colon.
:: Backup Type: rolling (all are copied to one dated directory), or mirrored (maintain one exact duplicate).
:: Test by commenting out large backup folders.

:List
::
::  Echo Source, Target, and Type of backups, then exit.  Set up new directory backups here by adding to echo list.
::
if /i not {%1}=={/list} goto DriveList
::
::echo source;target;type
::
@echo off
echo D:\xxx
echo D:\Ax
echo D:\xxx
echo \\xxx
echo \\xxx
goto exit
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::


:: Check first argument, if '/drives' echo drives and mountfolders, then exit.
:: Make sure catch-all drive is last

:DriveList
::
::  Echo the drive letters or mountpoints(folders) to consider for the backup.
::
if /i not {%1}=={/drives} goto Setup
::
::echo drive: or mountpoint
::
@echo off
echo D:\Backups\USB\010-Mon-Wed
echo D:\Backups\USB\020-Tue-Thu
echo D:\Backups\USB\030-Fri
echo J:
goto exit
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::



:Setup
::
set Designator=xxx
set MyBatchName=%~f0
set MyBatchPath=%~dp0
set BackupErr=%MyBatchPath%\BackLog.txt
set VerifyFile=00Verify.txt
set MinSpace10MB=1500
set DeleteMax=3
set DayOfWeek=%Date:~0,3%


:FindDrive
::
:: Find which drive will accept a backup for today
:: Process a list of drive letters that would have a USB drive, or 'last resort' share on another server.  
:: Use the first drive having a verify file containing today's DayOfWeek.
::
set BackDrive=NONE
for /f "tokens=1" %%i in ( '%MyBatchName% /drives' ) do call :PDrives "%%i"
if {%BackDrive%}=={NONE} goto NoBackup


:SetBackParms
::
set RollDir=%BackDrive%\Backup_%Designator%\Rolling
set RollPath=%RollDir%\%Date:~10,4%-%Date:~4,2%-%Date:~7,2%-%DayOfWeek%
set RollLog=%RollPath%\BackLog.txt
set RollLogOpt=/log
set MirrPath=%BackDrive%\Backup_%Designator%\Mirrored
set MirrLog=%MirrPath%\BackLog.txt
set MirrLogOpt=/log


:CheckSpace
::
:: This section checks space and deletes rolling folders if available.  
:: Prevent runaway.  Don't delete more than 'DeleteMax'
::
set DeleteCount=0
:CheckDrive
if %DeleteCount% GEQ %DeleteMax% goto BackItUp
::
:: How much space is left on the drive? Find bytes remaining (no commas), then strip last 7 characters
:: which approximates number of 10MBs.  Compare with arbitrary amount "MinSpace10MB".  Batch script compare
:: has a problem with REALLY big numbers (>= ~ 32000), so reduce compare 'magnitude' to quantities of 10MBs.
::
for /f "tokens=3" %%A in ('dir /-c %BackDrive%\ ^| find /i "Dir(s)"') do set DriveSpace=%%A
set DriveSpace10MB=%DriveSpace:~0,-7%
if %DriveSpace10MB% GEQ %MinSpace10MB% goto BackItUp
::
:: Not enough space, so delete the oldest 'rolling' backup directory. List in reverse date order,
:: then delete the last backup folder in the list, which should be the oldest.  
::
if not exist "%RollDir%" goto CantDelete
set KillDir=NONE
for /f %%A in ('dir "%RollDir%" /b /a:d /o:-d' ) do set KillDir=%%A
if {%KillDir%}=={NONE} goto CantDelete
rd /s /q "%RollDir%\%KillDir%"
set /a DeleteCount=%DeleteCount%+1
goto CheckDrive


:BackItUp
::
:: Get the backup directories listing by calling *this* batch script with /list parm
::
for /f "delims=; tokens=1-3" %%A in ('%MyBatchName% /list') do call :PRobocopy "%%A" "%%B" %%C
goto exit


:CantDelete
::
echo. >> %BackupErr%
echo The Daily Backup operation cannot begin. >> %BackupErr%
echo Unable to delete data from drive %BackDrive% for %DATE%. >> %BackupErr%
goto exit


:NoBackup
::
echo. >> %BackupErr%
echo The Daily Backup operation cannot begin. >> %BackupErr%
echo No Drives are available for %DATE%. >> %BackupErr%
goto exit



::::::::::::::::::::::::::::::::::: Procs ::::::::::::::::::::::::::::::::::::
::

:PDrives
::
:: Check the drive has a verify file, and if so, pass each line to a routine to check a match for today.
:: Once BackDrive is set, don't test again, just exit and finally exhaust the drive list.
:: Input: %1=DriveLetter
::
if {%BackDrive%}=={NONE} (
   if exist "%~1\%VerifyFile%" (
     for /f "tokens=1" %%A in ( %~1\%VerifyFile% ) do if /i {%%A}=={%DayOfWeek%} set BackDrive=%~1))
goto :eof

:::::::::::::::::::::::::

:PRobocopy
::
:: Copy the drive into a rolling (dated) folder or into the mirrored folder (install flats, archived data, etc.)
:: Input: %1=Source, %2=Target, %3=Type(rolling or mirrored).  Default is 'rolling'
::
(set BackPath=%RollPath%)&(
 set BackLog=%RollLog%)&(
 set LogOpt=%RollLogOpt%)&(
 set Mirror=)
if /i {%~3}=={rolling}  (
 set BackPath=%RollPath%)&(
 set BackLog=%RollLog%)&(
 set LogOpt=%RollLogOpt%)&(
 set RollLogOpt=/log+)&(
 set Mirror=)
if /i {%~3}=={mirrored} (
 set BackPath=%MirrPath%)&(
 set BackLog=%MirrLog%)&(
 set LogOpt=%MirrLogOpt%)&(
 set MirrLogOpt=/log+)&(
 set Mirror=/mir)
::
md "%BackPath%"
echo This backup performed on %DATE% at %TIME%. > "%BackPath%\00datestamp.txt"
robocopy "%~1" "%BackPath%\%~2" /e /r:0 /w:0 /v /np %Mirror% %LogOpt%:"%BackLog%"
goto :eof



::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

I hope that helps narrow this down some.
:exit
ASKER CERTIFIED SOLUTION
Avatar of Chris Staunton
Chris Staunton
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial