Do you want to backup your complete partition or windows drive to an external storage? The easiest way to do so is using robocopy
.
Backup using Windows Explorer GUI
While copying using Windows Explorer, you may get several confirmation prompts that you need to address. This becomes frustrating when you are copying a large number of files. The copy operation is interrupted by these prompts. Therefore, you need to regularly check the copy status.
Backup using xcopy
command
xcopy
is a command line tool developed by Microsoft in 1986 to copy files and folders. For about two decades xcopy
was the most convenient tool to backup files and folders. It still works, but has some limitations. `xcopy` cannot copy files whose path names are longer than 254 characters. It throws “insufficient memory” error when it comes across a file with a large path name. Secondly, it cannot copy files that are open or are in use and it performs traditional single thread copy operation.
Backup using robocopy
command
robocopy
is another command line tool developed by Microsoft in 1996. Unlike xcopy
, this tool is still maintained by Microsoft. The last GA version for this tool was released in 2019 and is available in Windows 10 by default.
The robocopy
command
To use robocopy
command, first open windows command prompt in administrator mode. You can do that by searching for cmd
in your Windows Start Menu
and then selecting Run as administrator
.
If you want to backup your Windows Drive C:\
to an external storage, say F:\
, execute the following command in cmd
:
robocopy C: F:\MyBackup /MIR /copyall /zb /xjd /xjf /R:0 /W:0 /A-:SH
This will create a new folder MyBackup
in F:\
and backup all contents from C:\
into it. The full documentation for robocopy
can be found here.
Explanation of the parameters used:
C:
is your source folder, drive or partition. If you want to Backup only a certain folder, say your user folder, you can replace this with the folder path. E.g. C:\Users\Bob
F:\MyBackup
is the destination folder. If the folder MyBackup
does not exist, the folder will be created.
/MIR
option stands for MIRror. It copies the source folder including the sub-folders and if additional files are present at destination, they are removed.
/copyall
copies both data and properties of files like timestamp, security flags, ownership attributes, etc.
/zb
stands for Restartable Backup Mode. Restartable mode allows robocopy
to resume previously partially copied files. Backup mode will allow copying files that are locked or in use. This option requires the command prompt to be in Administrator mode.
/xjd
stands for eXclude Junction Directories. This option skips copying of soft link folders. This is opposite to the option /sl
. Following soft links or symbolic links can result in an infinite loop and having a never ending backup.
/xjf
stands for eXclude Junction Files. This option skips copying of soft link files.
/R:0
skips any retry attempt if reading a source file or folder fails. By default robocopy
will retry one million times with a delay of 30 seconds each, if the source object is not readable.
/W:0
skips any retry attempt if writing a destination file or folder fails. By default robocopy will retry one million times with a delay of 30 seconds each, if the destination path is not writable.
/A-:SH
removes system and hidden attributes from the destination files. It is required so that you can easily access your backup files in any other windows system.
Challenges
- Sometimes The destination folder
F:\MyBackup
may not be visible to you in Windows Explorer. In that case, you can access it by typing in the pathF:\MyBackup
in the windows explorer navigation bar or by enablingShow Hidden Files
andShow protected OS files
settings inFolder Options
of Windows Explorer. - You may have difficulty in accessing the backup files in other Windows machines. This is because the ownership of some files lies with your previous Windows machine. To fix that you can execute the following
takeown
andattrib
commands on Administrator Command Prompt of the new Windows machine:
takeown /F F:\MyBackup /A /R /D Y attrib -r -a -s -h "F:\MyBackup" /s
Note: By default robocopy
performs multi-threaded copy. It uses 8 threads to copy the files. I have found that 8 is the most optimal thread count to copy the files on my machine. If you want to increase the number of threads, you can specify it using the option /MT:n
. Example: /MT:32
Helpful article for IT administration.. Thanks
Thanks for the helpful article, everyone has an easy way to backup/copy files and the easy way for me is by using a Robocopy GUI alternative like Teracopy and Gs Richcopy360