Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Robocopy - exclude a lot of directories

Tags:

robocopy

I have problem with robocopy. I want to use it for backing up a system disc and I want to exclude some system folders. But it's still trying to copy some of these folders. My batch file is this:

robocopy c:\ l:\C\ /r:1 /w:1 /mir /dcopy:T /xjd /xjf /xj /copy:DT /log+: l:\RobocopyLogC.txt /xf "desktop.ini" /xd "$Recycle.Bin" /xd Config.Msi /xd MSOCache/xd Recovery /xd "System Volume Information" /xd Windows /xd "Program Files\Common Files" /xd "Program Files\Internet Explorer" /xd "Program Files\Reference Assemblies" /xd "Program Files\Uninstall Information" /xd "Program Files\Microsoft Analysis Services" /xd "Program Files\Microsoft Mouse and Keyboard Center" /xd "Program Files\Microsoft Office" /xd "Program Files\Microsoft Silverlight" /xd "Program Files\MSBuild" /xd "Program Files\Windows Defender" /xd "Program Files\Windows Journal" /xd "Program Files\Windows Mail" /xd "Program Files\Windows Media Player" /xd "Program Files\Windows Multimedia Platform" /xd "Program Files\Windows NT" /xd "Program Files\Windows Photo Viewer" /xd "Program Files\Windows Portable Devices" /xd "Program Files\Windows Sidebar" /xd "Program Files\WindowsApps" /xd "Program Files\WindowsPowerShell" /xd "Program Files (x86)\Common Files" /xd "Program Files (x86)\InstallShield Installation Information" /xd "Program Files (x86)\Internet Explorer" /xd "Program Files (x86)\Microsoft Analysis Services" /xd "Program Files (x86)\Microsoft Office" /xd "Program Files (x86)\Microsoft Silverlight" /xd "Program Files (x86)\Microsoft.NET" /xd "Program Files (x86)\MSBuild" /xd "Program Files (x86)\Reference Assemblies" /xd "Program Files (x86)\Temp" /xd "Program Files (x86)\Windows Defender" /xd "Program Files (x86)\Windows Mail" /xd "Program Files (x86)\Windows Media Player" /xd "Program Files (x86)\Windows Multimedia Platform" /xd "Program Files (x86)\Windows NT" /xd "Program Files (x86)\Windows Photo Viewer" /xd "Program Files (x86)\Windows Portable Devices" /xd "Program Files (x86)\WindowsPowerShell" /xd "Program Files (x86)\Windows Sidebar" /xd ProgramData\Microsoft /xd "ProgramData\Microsoft Help" /xd "ProgramData\Package Cache" /xd Users\Public /xd Users\Default /xd Users\userName2 /xd Users\userName\AppData\LocalLow\Temp /xd Users\userName\AppData\Local\Temp

I have tried a lot of things, but nothing helped. Can you help me?

like image 247
Shortik Avatar asked Jul 21 '14 17:07

Shortik


People also ask

How do I exclude multiple files in robocopy?

I preface them with "rc" (for robocopy), then some recognizable notation for the application or part of the file system in the robocopy command, then append "B" or "R" (for Backup or Restore), then "I" or "X" (for Include or Exclude), then "D" or "F" (for Directory or File).

How do I exclude a file type in robocopy?

The most important switches in this command are the /XD which allows you to exclude folders, and /XF that you can use to exclude files. The other options are optional, but you should use these options that you should use in any standard copy process using Robocopy.

What is robocopy XD?

Robocopy allows you to filter items not just by file but by directory name too. Using robocopy /xd , you can exclude certain directories matching a specific name. When copying multiple folders, use the /XD switch to exclude folders from the run.

Is robocopy or XCopy better?

The average Disk Write Transfer is better for Robocopy (50.30 MB/Sec vs. 43.76 MB/Sec), the minimum Disk Write Transfer is better for Robocopy (0.39 MB/Sec vs. 0.00 MB/Sec) and the maximum Disk Write Transfer is better for XCopy (133.27 MB/Sec vs. 113.15 MB/Sec).


1 Answers

Dont use multiple /xd! Just set all the directories behind the first /xd

... /xd "dir1" "dir2" "dir3" ...
like image 172
Phab Avatar answered Oct 22 '22 12:10

Phab