|
Answer» I'm running Windows XP and I've just wrote a batch file for backing up my stuff on an external hard-drive. I use the XCOPY command with the following switches: /D/E/I/H/K/Y.
It works fine except that I don't end up with a mirror image of the original source structure, because everything that I deleted since the last backup is obviously not deleted by the xcopy command ...
The easy solution would be to delete everything first, and then use xcopy ... but then, I loose the benefit of the nice /D switch because every file would be recopied each time and that takes quite a while ...
Is there a DOS command or some clever code that I could run after xcopy that would quickly compare both structures (source and backup) and remove all files and folders that are in excess in the backup structure, so that source and backup are identical ?
A batch file beginner :oP
I don't think there is any way to do it with a batch file. You get into some real complicated issues here. Sophisticated backup systems OFTEN handle this issue by CREATING a catalogue of all the files, with date and time stamps, that are on the source disk at backup time. Then if there is a restore, the system REFERS to that catalogue and restores only what is listed in it, rather than everything it finds on the target disk. Mmmmmhh ... and I guess that any elaborate code I would write in order to compare source and DESTINATION would run just as slow as deleting and then copying everything ...
Ok, so I'll first delete everything with: rmdir /S/Q ... and also remove /D of xcopy since it would be obsolete ...
This "compare and clean excess" behavior would be a nice switch to add to xcopy ...
Thanks for answering me !
|