Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm trying to copy some directories from a server before I restore from backup (my latest backup was corrupt, so I have to use an older one :( ). I'm in the Windows Recovery Environment and have access to the server's file system G:\ and my backup media C:\. But, since I'm more familiar with Linux, I'm having a bit of trouble with the command line in Windows, specifically robocopy.

I want to copy multiple directories (maintaining the same directory structure) from G:\ to C:\ while excluding others (namely, the Windows and Program Files folders). I can't figure out the syntax for the /XD option. I was hoping to do something like:

robocopy G: C:\backup /CREATE /XD "dir1","dir2", ...

NOTE: I want to clarify that I want to copy the actual files while maintaining the directory structure too. I just checked, and /create only creates empty files. Weird.

share|improve this question

1 Answer 1

up vote 16 down vote accepted

I figured it out with a little trial and error and the /L (to test the command before doing it for real). The command I end up with is:

robocopy G: C:\backup /MIR /XD G:\dir1 "G:\dir 2" G:\dir3 ...

Apparently, including trailing slashes keeps robocopy from parsing the list of directories correctly, so be sure not to include trailing slashes on directory names and remember to put quotes around directories with spaces in the name.

The /MIR option maintains the same directory structure while copying the files.

Edit: After some more research, I improved the command a bit:

robocopy G: C:\backup /MIR /Z /LOG:C:\todaysdate-backup.log /XF *.iso *.log *.au /XD G:\dir1 ...

The additions are as follows:

  • /Z allows the job to be restarted
  • /LOG:<logfile path> is pretty self-explanatory.
  • /XF is being used to exclude certain filetypes so it doesn't take so long
share|improve this answer
    
You can always use the /? switch to get help information for Windows console commands. There's also the help command, which similar to Linux's man program, but I haven't seen it used by third-party programs (it could be--I am not familiar with how it works, or if that's even possible). –  Ben Richards Oct 1 '12 at 22:18
    
Hey, thanks for the comment. I thought there was a help command, but it doesn't seem to be active in the Windows Recovery Environment (I received an error like "No command 'help' found"). Robocopy is a windows default command that replaced xcopy and is not 3rd-party. –  GorrillaMcD Oct 1 '12 at 22:38
1  
I know it's a Windows command and not 3rd party. I just put that in there just for future reference's sake, since you said you aren't as familiar with Windows' command environment. :) –  Ben Richards Oct 1 '12 at 23:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.