My Backup.bat File dilemma

I have a backup file that I have scheduled nightly to run. The content of the backup file is below:


xcopy "c:\data" "f:\backup\data" /e/i/d/h/r/k/y
xcopy "c:\data" "d:\backup\data" /e/i/d/h/r/k/y


I have been using this technique to backup my stuff since years and it works perfectly. It basically, copies everything new or changed from the source location (c:\data) to the destination (f:\backup\data & d:\backup\data). The only problem with this approach is that it doesn’t take care of the files and folders that I delete in the source location.

All you MS.DOS pros out there, help me out with my batch file to add this new functionality. I basically want it to delete everything from the destination that doesn’t exists any longer in the source. I could place a line that would do a delete all in the backup\data folder but that would be a lot of unnecessary activity I think.

Re: My Backup.bat File dilemma

wat a dive by inzi… surely trying his best to lead pak to victory… Go inzi :jhanda:

Re: My Backup.bat File dilemma

Inzi is good with the .bat :k:

Re: My Backup.bat File dilemma

^^ :hehe:

You need some kind of comparison mechanism.. I think TB could be of help ( as always)

Re: My Backup.bat File dilemma

whooops… Sorry Asif2000…
n sorry gupshup for thinking that you ate my inzi post in cricket forum :frowning:

i will ask someone that knows abt this… it will be a sweet thing…

p.s. nice n simple command to do backups… people spend hundreds of $ on backup software n still don’t get it right … good thinking… :k:

Re: My Backup.bat File dilemma

Asif, try using a product called Windiff. This product can be cusomized with the command line interface, it does a compare on two directories and you can copy/move/delete files based on the comparison.

Re: My Backup.bat File dilemma

I have used a little utility called Idem in the past to do just that. It has a switch "mirror" which appends new/updated files and deletes destination when source gets deleted.

Re: My Backup.bat File dilemma

Thanks for all the replies.

I am trying to keep it simple and avoid any external apps. For now, I have decided to create another batch file (DeleteBackup.bat) that I will schedule to run once a week only unless anyone has any other ideas.


rmdir "f:\backup\data" /s/q 
rmdir "d:\backup\data" /s/q


Re: My Backup.bat File dilemma

Use robocopy with the /MIR switch. I have using that for the last 5 years. It will mirror the source onto backup location.