There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
access audio avg avg 8 bios blue screen boot bsod computer connection cpu crash css dell desktop dma driver drivers dvd email error excel explorer firefox firefox 3 freeze gimp graphics hard drive hardware hijackthis hjt install internet internet explorer itunes keyboard laptop macro malware monitor motherboard network networking outlook outlook 2003 outlook 2007 outlook express pio problem problems router seo server slow sound sp3 spyware trojan usb video virtumonde virus vista vundo windows windows vista windows xp winxp wireless
DOS/PDA/Other
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Operating Systems > DOS/PDA/Other >
Using DOS batch files to perform a backup


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
GatinGamer's Avatar
Junior Member with 3 posts.
 
Join Date: Nov 2007
Experience: Intermediate
18-Nov-2007, 02:13 PM #1
Using DOS batch files to perform a backup
So I have a rather puzzling situation. I've decided that paying for backup software when all I really want out of this backup is to copy the folders exactly makes no sense, and doing that manually is a bad option because I want an automated backup. I have written a batch file that will copy the folders using xcopy, thus performing a full backup of the needed data. I want to make a second batch file that will perform a synthetic full backup, in case you are unfamiliar with the term it's basically using xcopy with the /D option where the date is the last date a backup happened. I think the best way to do this is to use the DOS date function as input to a text file and then read the last run date from a text file when i start the backup. Only trouble with doing it this way is that the date function returns the date with a day of the week and xcopy requires the date without. So far I have attempted to write the output to a file then read from a different file but am having trouble figuring out how to parse it properly. My current method is involving C and is going to require a second script. Is there some way that I can do this using just one batch and one text file?
ChuckE's Avatar
Senior Member with 1,854 posts.
 
Join Date: Aug 2004
Location: Redondo Beach, CA
Experience: Advanced
18-Nov-2007, 06:48 PM #2
If you use the XCOPY /D with no date given, then it copies only those files whose source time is newer than the destination time. So then, only files that have been updated will be copied.

What's wrong with that? Won't it do what you want?
GatinGamer's Avatar
Junior Member with 3 posts.
 
Join Date: Nov 2007
Experience: Intermediate
18-Nov-2007, 06:56 PM #3
Well see the tricky part is I don't just want to copy the files that have changed, I want to copy the files that have changed since a given date. I ended up writing a C function to do the date parsing I needed and compiling it as an executable and calling that from within the batch script.
ChuckE's Avatar
Senior Member with 1,854 posts.
 
Join Date: Aug 2004
Location: Redondo Beach, CA
Experience: Advanced
18-Nov-2007, 09:00 PM #4
Automatic Copying By Date
You might want to look over this guy's solution: AUTOMATIC COPYING BY DATE.
GatinGamer's Avatar
Junior Member with 3 posts.
 
Join Date: Nov 2007
Experience: Intermediate
18-Nov-2007, 09:09 PM #5
That link, though useful, only does a portion of what I was looking for. It will copy by default anything updated today or before the date i type in. If I run that everyday it mimics the functionality I have coded for, I was planning on running it on Monday, Wednesday, and Friday so I need it to store those dates somewhere. I just wrote a small C program to do that for me and did the rest with the batch file.
ChuckE's Avatar
Senior Member with 1,854 posts.
 
Join Date: Aug 2004
Location: Redondo Beach, CA
Experience: Advanced
18-Nov-2007, 09:21 PM #6
There is still a way by using the DOS AT /every:date,M,W,F yourbatch.bat command,
(or whatever you might want in the "yourbatch.bat" position).
TheOutcaste's Avatar
Computer Specs
Senior Member with 1,609 posts.
 
Join Date: Aug 2007
Location: Oregon, USA
Experience: Intermediate
26-Nov-2007, 02:35 PM #7
The set command allows you to extract a substring from a variable:
for example:
Code:
date /t >c:\lastbackup.txt          ;lastbackup.txt now has Mon 11/26/2007
set /p mydate= <c:\lastbackup.txt   ;mydate now equals Mon 11/26/2007
set mydate=%mydate:~4%              ;mydate now equals 11/26/2007
you can now use %mydate% in the xcopy command

see help for the set command
HTH

Jerry
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 03:57 PM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.