daily backup bat file

Score
0
Vote Up
September 19, 2005 at 20:35:27 Pacific
Specs: ms-dos 6.22, PIII/512

Would like to backup(xcopy) files to a different directory for each day of the week. Batch file needs to determine day(Sunday-Saturday)automatically, and then copy data files from the application working directory to the appropriate day's backup directory.

Reply ↓  Report •


#1
Vote Down
Score
6
Vote Up
September 19, 2005 at 22:46:09 Pacific

The first hump to get over is getting the DAY into a variable for use by the backup bat.

This will get DAY, DATE and TIME into varibles.

:: DtimeDOS.bat
@echo off

echo.|date>datevar.bat
echo.|time>timevar.bat

echo set DATEvar=%%4>current.ba
call datevar

echo set DAYvar=%%3>current.ba
call datevar

echo set TIMEvar=%%3>current.ba
call timevar
:: done

Note that it may need to be tailored becase the output of the DATE & TIME will vary according to version, language, codepage etc.

Once you get that hammered out:

cd c:\appdata
xcopy . c:\DAYvar\


If at first you don't succeed, you're about average.

M2


Reply ↓  Report •

#2
Vote Down
Score
2
Vote Up
September 20, 2005 at 17:56:38 Pacific

M2,

Many thanks for the help. Looks like that will get the date up in a numerical format ok. Any ideas on how to translate that to day of the week, ie; Sunday, Monday, etc. I want to have seven backup directories so I can have a rolling week of backups?

EGB


Reply ↓  Report •

#3
Vote Down
Score
3
Vote Up
September 20, 2005 at 18:50:54 Pacific

I saw this site the other day - he uses a program called XSET to simplify the process - seems to be what you're seeking.

If the xset link isn't working, try FileLibrary

Do Not Click


Reply ↓  Report •

#4
Vote Down
Score
4
Vote Up
September 21, 2005 at 13:59:05 Pacific

Hi
Put the Weekday.com code into a text file.
Put a blank line after the last Q.
Save it as Weekday.scr then enter this
on the command line.
debug < Weekday.scr
this creates Weekday.com

Create the second batch file and modify
the "echo it's" to the code required for
the day of the week.
---------------------------
N WEEKDAY.COM
A 100
MOV AH,2A
INT 21
MOV AH,4C
INT 21

R CX
8
W
Q

--------------------------
@echo off
weekday.com
if errorlevel 0 if not errorlevel 1 goto Sunday
if errorlevel 1 if not errorlevel 2 goto Monday
if errorlevel 2 if not errorlevel 3 goto Tuesday
if errorlevel 3 if not errorlevel 4 goto Wednesday
if errorlevel 4 if not errorlevel 5 goto Thursday
if errorlevel 5 if not errorlevel 6 goto Friday
if errorlevel 6 goto Saturday

:Sunday
echo It's Sunday
goto Done
:Monday
echo It's Monday
goto Done
:Tuesday
echo It's Tuesday
goto Done
:Wednesday
echo It's Wednesday
goto Done
:Thursday
echo It's Thursday
goto Done
:Friday
echo It's Friday
goto Done
:Saturday
echo It's Saturday
:Done


Reply ↓  Report •

Related Posts

#5
Vote Down
Score
0
Vote Up
September 24, 2005 at 19:09:23 Pacific

Wow!!!

You guys are really great.

DOS still lives.

Thanks again.

EGB


Reply ↓  Report •

#6
Vote Down
Score
3
Vote Up
September 24, 2005 at 21:11:47 Pacific

As per #1:

"Note that it may need to be tailored becase the output of the DATE & TIME will vary according to version, language, codepage etc."


If at first you don't succeed, you're about average.

M2


Reply ↓  Report •

Reply to Message Icon Start New Discussion
« MBRtool syntax IBM DOS 3.3 word pro... »

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.

Ask the Community!
Describe your Problem
Example: Hard Drive Not Detected on My PC