Click an area from the above list to jump directly to that section.
001. :HEADER [Script
Information Block]
016. :
=============================================================================
017. : -> TSG_Snapshot.cmd
2004.04.24 (create a backup whenever a file changes)
018. :
=============================================================================
019. : File
Name.............TSG_Snapshot.cmd
020.
: File Location.........PlaceLocalPathHere
021. : Coded
By..............TheSystemGuard
022. : Service
Date..........2004.04.24
023. : Last Revised
By.......TheSystemGuard
024. : Revision
Date.........2004.04.24
025. :
=============================================================================
028. :PRELIM [Common to all
scripts]
035. :SETUP [Specific to this script]
037. :* If no parameters or switches are specified, show syntax and exit with EL=1
040. :* If the first
parameter contains [/? -? /help -help], show help screen and exit
042. :* Initialize
any available Library - brief method
051. :* Make sure
Command Library is initialized
078. :Bgn_Parse
[parse the command line]
080. :GetSwitches [process any command line switches]
085.
:GetParms [process any parameters]
087. :* Clear/Reinitialize all variables just in case
they were set from previous runs
103.
:* Retrieve the file to save
106.
:* If no file was specified, go to the ERROR section
112.
:* If the specified file cannot be found, go to the ERROR section
120.
:* Retrieve the name of the folder to store snapshots, if specified
123.
:* If no SafePlace was specified, set SafePlace to C:\!Snapshot
126.
:* If the SafePlace folder doesn't exist, try to (silently) create it.
129.
:* If there was an error creating the folder, go to the ERROR section
135.
:* If an Interval was specified, try to use it
140.
:* If Interval is less then 1 minute (or blank), default to 5 minutes
145. :End_Parse
149. :Help
[full help screen]
246. :Syntax
[brief syntax display]
257. :WORK [This is where
the job actually gets done]
259. :* Valid
parameters are assumed at this point
261.
:* FileToSave=a specified file that DOES EXIST
262.
:* SafePlace=a specified folder (or "C:\!Snapshot") that DOES EXIST
263.
:* Interval=a specified number of minutes (or the default of 5)
265. :* Convert the
numeric interval to seconds
266. :* Clear
the #LogDate and #LogTime before entering the loop
274.
:Bgn_Loop
276.
:* Check the file Latest.FileToSave.Ext in the SafePlace folder
277.
:* _ If it's current, go to the wait loop, if not, make a copy
283.
:MakeSnap [make a copy]
285.
:* Process any pre-existing snapshots
305.
:* Try to take a new snapshot
311.
:* Update counters (either good or bad)
320.
:* Update console message
333.
:Current [snapshot is current]
341.
:Wait [wait for IntervalTime]
343.
:* Add one to the passes counter, update the total minutes waited
358.
:End_Loop
360. :VERIFY
[Commands to verify any actions taken]
366. :NOTIFY [Commands to
report what happened]
377. :FINISH [Cleanup
commands for a normal or expected ending]
381. :* If there has
been at least 1 SnapShot Pass, show the finish line
388. :* Uninstall the
library (removes all traces)
397. :ERROR [Display any
error message and set errorlevels]
403. :* Show error in
title bar and at console via STDERR |