I need to throw together a simple batch file to backup a file. I will
schedule this via Task Scheduler to run every hour or so. I will have the
file go to a compressed folder but space will still be an issue. I would
like to create a second batch file that I will schedule to delete 'some' of
the files to make room. I have done something like this via vbscript and wsh
in the past put for times sake I want to keep this quick and simple. 2 files
are fine.
any suggestions on the cleanup part? I need to delete only some of the
files... not all.
Actually, now that I'm thinking about it a little, I used some string
manipulation with vbscript to make unique file names for each copy (using
the now() function and striping invalid characters for filenames). How will
I get unique filenames just using a batch file? Is this going to be simpler
or more complex?
any input is appreciated. My goal is something very simple. (all windows
2000 machines by the way)
thanks.
The Advanced Version of Snapshot will create date/time coded backups that
can be easily processed for deletion based on whatever criteria you decide.
This script is included with the FREE Advanced NT/2K/XP/K3 Command Library
from (
http://ntlib.com). Help screen follows (watch for line wraps):
*******
^
=========================================================================
/~\ Snapshot Advanced Release 2004.03.28 (Free from TheSystemGuard.com!)
/cmd\
=========================================================================
Create a snapshot backup when a file changes.
____________________________________________________________________________
___
TSG_Snapshot [/?] [drive:][path]FileToProtect [SafeLocation] [Interval]
SWITCHES:
/? Display this help.
PARAMETERS: Default values are shown in {}'s
FileToProtect A SINGLE file to protect (no wildcards!)
[SafeLocation] Folder to hold snapshots {C:\!Snapshot}
[Interval] Minutes between file checks {5}
ERRORLEVELS:
0 = Normal or expected finish.
1 = Help screen was displayed.
2 = Script exited with a known error. See %ErrorMsg% for details.
3 = Script exited with an unspecified error.
NOTES:
The SafeLocation folder will be created if necessary.
Interval time DOES NOT include time spent comparing and copying files.
The Interval counter is reset at the beginning of each waiting period.
Actual wait time is NOT PRECISE, and can overshoot by several seconds,
depending upon system load (see the .Wait command).
If any optional parameter is used, all optional parameters to it's left
MUST
be specified. For example, to use Interval, also specify SafeLocation.
All Advanced Scripts (those prefixed with "TSG_") from TheSystemGuard.com
REQUIRE the Advanced NT/2K/XP/K3 Command Library (ntlib.cmd). This library
provides over 200 resources for writing, testing and maintaining RELIABLE
shell scripts using only the native commands and utilities that are present
in
ALL NT-based operating systems. Write a script ONCE using ntlib.cmd and
your
script will perform CONSISTENTLY under Windows NT4, 2000, XP and Server
2003!
Request your FREE copy of the Advanced Library today at (
http://ntlib.com).****************************************************************************
***
Snapshot Expert uses the enlarged "Expert Command Library" (NTCmdLib.cmd),
enabling many additional command line switches and parameters. All Expert
Scripts (those prefixed with "!") are complete, ready-to-run applications
that do not require any commands or utilities not already present in every
NT/2K/XP/K3 install. !Scripts are distributed uncompressed and are fully
commented so you can quickly fashion them to your specific requirements.
An example of what you're missing (from the help screen of !Snapshot.cmd):
SWITCHES: Default values are shown in {}'s
/C Compact window during run (size restored at Final Report). {off}
/FP FullPath (use the full path of FileToProtect in window title)
{name.ext}
/NV NoVisual (don't change console colors to reflect operating status)
{on}
/P Pause (pause console after Final Report) {off}
/WF WaitforFile (bypass error if FileToProtect does not exist) {off}
PARAMETERS: Default values are shown in {}'s
[Warning_Trigger] Consecutive missed snapshots before warning. {1}
[Error_Trigger] Consecutive missed snapshots before error. {2}
[MaxSnaps] Maximum snapshots to take before stopping. {25}
[MaxTime] Maximum time (in minutes) to wait. {480} (8
hours)
!Snapshot.cmd provides a color-coded, self-adjusting console window to
enable
at-a-glance monitoring of all running snapshots while using minimum desktop
real estate. We also include a ".reg" file to allow right-click access to
the
!Snapshot script from inside Windows Explorer. Just highlight any file,
then
right-click, and select "Protect with !Snapshot".
Both the Expert Command Library and !Snapshot are "Almost Free" at $9 or
less!
See (
http://TheSystemGuard.com/AlmostFree.asp) for The Almost Free Price
List.
The VERY LATEST KNOWLEDGE pertaining to the Windows NT/2K/XP/K3 command
line
can be found at TheSystemGuard.com. Check the MasterCatalog often for a
continually growing collection
(
http://TheSystemGuard.com/MasterCatalog.asp).
You'll learn to build RELIABLE and MAINTAINABLE shell scripts that will
always
perform CONSISTENTLY on every Windows NT-based system right out of the box!
Don't forget our FREE KnowledgeLetter at (
http://BoomingOrFuming.com)
and...
Congratulations On Your Decision To RISE ABOVE THE REST!!!
____________________________________________________________________________
___
TSG_Snapshot [/?] [drive:][path]FileToProtect [SafeLocation] [Interval]
*******
For more information, see the Snapshot Page at
(
http://TheSystemGuard.com/Scripts/Snapshot).
An overview of what the script does is at
(
http://TheSystemGuard.com/Scripts/Snapshot/TSG_Snapshot.outline.htm)
The complete commented cmdsrc ("Cmd Source") is at
(
http://TheSystemGuard.com/Scripts/Snapshot/TSG_Snapshot.cmdsrc.htm)
*******
-tsg
/-----------------+---------------+----------------------\
| COMPATIBILITY | CLARITY | SPEED |
| Write code ONCE | Make it clear | THEN...Make it fast! |
\-----------------+---------------+----------------------/
400+ command-line resources using ONLY native NT commands!
(
http://TheSystemGuard.com/default.asp#MasterCommandList)