Backing (Using Copy or Xcopy) Up to Datestamped Directory

I'm using Windows 2000 Server.  I want to make a nightly backup, prefereably with "copy" or "xcopy" from c:\sourcedir to h:\backup<date>.  I want to do this each night and want the target directory named with a datestamp (e.g. "h:\backup20070730").  I know how to use scheduler to set it up once the bat file is written.  I need to write the bat file.
bhungerAsked:
Who is Participating?
 
amit_gConnect With a Mentor Commented:
@echo off

for /f "tokens=1,2" %%u in ('date /t') do set d=%%v
set datestr=%d:~6,4%%d:~0,2%%d:~3,2%

set Source=c:\sourcedir
set Destination=H:\Backup%datestr%

xcopy /I /E /Y /M /C /R /V /K /H %Source% %Destination%
0
 
bhungerAuthor Commented:
Works great except that only the directories and subdirectories are copied onto the H: dirve.  The files in the directories are not copied.
Thanks
0
 
amit_gCommented:
The xcopy flags that I have used may be causing it. I use these for some of my backups. Take out /M. Check the meaning of these flags by checking those by doing xcopy /?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.