Robocopy Examples

Robocopy Examples

Robocopy is a powerful, robust, and Windows-native command-line tool for copying files, folders, and even syncing directories β€” especially useful for backup, migration, or bulk copying.


βœ… Robocopy Basics

robocopy [source] [destination] [/options]

🎯 Example: Copy a Folder and All Its Files

βœ… Basic Copy (with subfolders)

robocopy "C:\SourceFolder" "D:\DestinationFolder" /E /COPY:DAT /R:10 /W:5

πŸ” Breakdown of Options

OptionDescription
/ECopy subdirectories and empty directories too.
/COPY:DATCopy data, attributes, and timestamps β€” preserves file metadata.
/R:10Retry up to 10 times if a file fails to copy.
/W:5Wait 5 seconds between retries.
/LOG+:C:\backup.logLog output to a file β€” useful for debugging or tracking.
/ZCopy files even if they’re open (useful for files being used by programs).

🧩 Example: Copy with Logging

robocopy "C:\SourceFolder" "D:\DestinationFolder" /E /COPY:DAT /R:10 /W:5 /LOG+:C:\backup.log

This logs the copy operation to C:\backup.log.


πŸ“Œ Example: Copy Without Overwriting

robocopy "C:\SourceFolder" "D:\DestinationFolder" /E /COPY:DAT /R:10 /W:5 /Z /COPY:DAT

This copies files without overwriting β€” if a file already exists, it will not overwrite it.


πŸ“‚ Example: Copy with Overwrite (Default)

robocopy "C:\SourceFolder" "D:\DestinationFolder" /E /COPY:DAT /R:10 /W:5

This copies all files β€” and overwrites existing files.


🧠 Pro Tips

  • Use /LOG+:C:\backup.log to track what’s copied β€” very useful for debugging.
  • Use /Z if you’re copying files that are being used (e.g., by a program).
  • Use /COPY:DAT to preserve file metadata (timestamps, permissions, etc.).
  • Use /E to copy empty directories too.

πŸ“„ Example: Copy a Folder with Logging

robocopy "C:\SourceFolder" "D:\DestinationFolder" /E /COPY:DAT /R:10 /W:5 /LOG+:C:\backup.log

🚫 Common Mistakes

  • ❌ robocopy C:\Folder D:\Folder β€” Wrong! You must specify the folder name.
  • ❌ robocopy C:\Folder\ D:\Folder\ /E β€” Wrong! You need to specify the folder name.
  • ❌ robocopy C:\Folder\ D:\Folder\ /E /I β€” Wrong! You need to specify the folder name.

βœ… Correct: `robocopy “C:\Folder” “D:\

I hope this helps you as much as it has helped me with my Windows backups.