Need a small batch for backup

M

Mike Stephen

I have a small client that needs a simple backup solution.

I have decided that the cheapest hardware backup solution is
a removable hard disk (a tray with tow 80 gig hard drives to
be swapped out back and forth on a daily basis. What I
would like is a small batch file that will use the copy or
xcopy command to backup all the files in the "my documents"
folder to the d drive (the 80 gig removable) What I would
like is the ability to make a directory on the backup drive
named as the current date in dd/mm/yy format, (obviously
without the slashes), then proceed to copy all the file into
that dir. This way the 80 gig drive would eventually fill
up after about 90 days and the old backups could ten be
deleted. I will send me the log file so that I can keep an
eye on it with a sendmail....

Is there a simple batch type line (or two-three) that I
could include in a batch file?

It has been many years since I have programmed and when I di
it was with simple batches and rexx scripts. Anyone have a
similar need and more skill than I, that could help?
 
P

Paul R. Sadowski

Well, this is how I'd do it but some might complain because it's not all
batch but it's simple and easily modified.

@echo off
setlocal
for /f %%c in ('cscript c:\bin\tdate.vbs') do set backupdate=%%c
[YOUR STUFF HERE]

Where tdate.vbs is (for yyyymmdd form)
Mn = Month(Now)
Dy = Day(Now)
Yr = Year(Now)
wscript.echo Yr & right("00" & Mn, 2) & right("00" & Dy, 2)

Or for the ddmmyyyy form
Mn = Month(Now)
Dy = Day(Now)
Yr = Year(Now)
wscript.echo right("00" & Mn, 2) & right("00" & Dy, 2) & Yr
 
P

Paul R. Sadowski

Paul R. Sadowski said:
Or for the ddmmyyyy form
Mn = Month(Now)
Dy = Day(Now)
Yr = Year(Now)
wscript.echo right("00" & Mn, 2) & right("00" & Dy, 2) & Yr

Damn, should be
wscript.echo right("00" & Dy, 2) & right("00" & Mn, 2) & Yr

and if you really want only a two digit year then use this:
Yr = Right(Year(Now),2)
 
G

guard

I have a small client that needs a simple backup solution.

I have decided that the cheapest hardware backup solution is
a removable hard disk (a tray with tow 80 gig hard drives to
be swapped out back and forth on a daily basis. What I
would like is a small batch file that will use the copy or
xcopy command to backup all the files in the "my documents"
folder to the d drive (the 80 gig removable) What I would
like is the ability to make a directory on the backup drive
named as the current date in dd/mm/yy format, (obviously
without the slashes), then proceed to copy all the file into
that dir. This way the 80 gig drive would eventually fill
up after about 90 days and the old backups could ten be
deleted. I will send me the log file so that I can keep an
eye on it with a sendmail....

Is there a simple batch type line (or two-three) that I
could include in a batch file?

It has been many years since I have programmed and when I di
it was with simple batches and rexx scripts. Anyone have a
similar need and more skill than I, that could help?

The .Mount/\Command ".GetLogDate" will CONSISTENTLY display the date as
"yyyymmdd" under NT/2K/XP/K3 regardless of the local date format using no
external utilities. The value is also saved to variable "#LogDate".

The general syntax would be :

D:
%.GetLogDate%
MD %#LogDate%
XCOPY ...etc.

*******

The above will make a directory as yyyymmdd, which is easier to sort than
ddmmyy. If you really want the latter, then convert #LogDate to ddmmyy
format using:

SET #LogDate=%#LogDate:~6,2%%#LogDate:~4,2%%#LogDate:~2,2%

For a color-keyed example, see
(http://TheSystemGuard.com/MtCmds/GetValue/GetLogDate.htm).

*******
Notes:

1. .Mount/\Commands are constructed using ONLY builtin
commands common to all four platforms (NT/2K/XP/K3).
2. .M/\C's are NOT case sensitive. Mixed case is used
for Visual Clarity only.

*******

TheGuardBook contains a "Mounted Help" page for each internal cmd.exe
command. This is a single color-coded page, highlighting the differences
among the NT/2K/XP/K3 versions. The complete help text for each OS is also
available for comparison (http://TheSystemGuard.com/TheGuardBook/CCS-Int).

*******

-tsg
____________________________________________________________
TheSystemGuard.com | BoomingOrFuming.com | MountCommands.com
Free and "Almost Free" Knowledge for Windows System Admins!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top