0

I am working on some code for a friend. This is what I have so far. It is supposed to be a backup script.

@echo off
title Backup Script
color 5a
if exist E:\backup goto prev
mkdir E:\backup
goto prev
:prev
echo Press any key to start Backup...
pause>nul
rd E:\backup /s /q
mkdir E:\backup\Desktop
mkdir E:\backup\Documents
msg * "Do not Close out previous Windows until Done."
copy "C:\Documents and Settings\Person\Desktop" "E:\backup\Desktop"
copy "C:\Documents and Settings\Person\My Documents" "E:\backup\Documents"
echo "Finished! Press any key to Exit."
pause>nul
exit

But whenever I make a change in the originating directory, it does not show on the backup drive.

Thanks for any help!

drcomputer
  • 406
  • 2
  • 7
  • 15
  • What do you mean ? It don't do the copy ? You'll better use `robocopy` to just copy the new files or delete the files who don't exists anymore (`/purge` switch) – SachaDee Jan 26 '15 at 13:15

1 Answers1

0

The copy command is for copying files, not directories. If you want to copy a directory tree, consider using xcopy, or as SachaDee suggests, robocopy. As a bonus, robocopy /XO can skip files that have already been backed up that haven't changed. Then you wouldn't have to rd /q /s e:\backup before every backup, and subsequent backups will go much more quickly. Full details on robocopy.

Community
  • 1
  • 1
rojo
  • 24,000
  • 5
  • 55
  • 101