| This is the command we use for backing up a directory. Among other things, it only copies files when a newer version is present, preserves file ownership and security, does not prompt the user, and does not break on errors and copies all subdirectories.
xcopy C:\Myfiles D:\Backup /c /d /e /h /i /k /q /r /s /x /y
As shown above, the xcopy command is used to copy all the files and folders [/s] newer than those already copied [/d], including empty folders [/e] and hidden files [/h], from source of C:\Important Files to the destination of D:\Backup, which is a directory [/i]. I have some read-only files I want to keep updated in destination [/r] and I want to keep that attribute after being copied [/k]. I also want to make sure I maintain any ownership and audit settings in the files I'm copying [/x]. Finally, since I'm running xcopy in a script, I don't need to see any information about the files as they're copied [/q], I don't want to prompted to overwrite each one [/y], nor do I want xcopy to stop if it runs into an error [/c].