• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 349
  • Last Modified:

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.
0
bhunger
Asked:
bhunger
  • 2
1 Solution
 
amit_gCommented:
@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

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now