Avantguard Computer & Security Systems

xcopy

xcopy — Extended Copy

xcopy is a powerful file copy utility included with Windows.

Full Backup Syntax

xcopy C:\Source D:\Destination /E /H /K /O /X /I /B /Y

Flags Explained

Flag Description
/E Copy directories and subdirectories, including empty ones
/H Copy hidden and system files
/K Copy attributes (preserve read-only flag)
/O Copy file ownership and ACL information
/X Copy file audit settings (implies /O)
/I If destination does not exist, assume it’s a directory
/B Copy symbolic links themselves (not the target)
/Y Suppress confirmation prompt to overwrite files

Common Examples

# Copy entire C: drive to D:\Backup
xcopy C:\ D:\Backup\ /E /H /K /O /X /I /B /Y

# Copy only newer files (incremental)
xcopy C:\Data D:\Backup\Data /E /H /D /Y

# Exclude specific files
xcopy C:\Source D:\Dest /E /EXCLUDE:exclude.txt

exclude.txt contains patterns (one per line):

\pagefile.sys
\hiberfil.sys
\Windows\Temp\