RoboCopy - File Transfer Tool

Updated: Feb 13

Article No :: KB00011



Robocopy is a “Robust File Copy” command-line command available for the Microsoft Windows machines. It is available as “robocopy.exe”. It copies files and directories from one location to another location.

It allows you to copy or transfer multiple files and folders in one go. It is not only can you copy/move files from one place to another, it takes care of other things as well like keeping permissions, copying folders, excluding certain files or copying certain files and many more.

Windows Version Supports

Windows Server 2008 & 2008 R2

Windows Server 2012 & 2012 R2

Windows Server 2016

Windows 7

Windows 8

Windows 10

Note: Earlier version also supports Robocopy, you need to download the robocopy command from Windows Resource Toolkit or Microsoft Website.


Command & Switches

In this article, we are going to cover only the basics since Robocopy has so lots of options. You guys can experiment the commands with various switches. You will get the information of all the switches by using the “robocopy /?” switch.


Open PowerShell or CMD and type Robocopy /? to get all the options of robocopy.


PS C:\> Robocopy /?

-------------------------------------------------------------------------------

ROBOCOPY :: Robust File Copy for Windows

-------------------------------------------------------------------------------

Started : 24 August 2019 11:52:13 AM

Usage :: ROBOCOPY source destination [file [file]...] [options]

source :: Source Directory (drive:\path or \\server\share\path).

destination :: Destination Dir (drive:\path or \\server\share\path).

file :: File(s) to copy (names/wildcards: default is "*.*").


Robocopy Switches and their details.

Examples:

Example 1:

Robocopy \\OldSharedFolder\Data \\NewSharedFolder\Data

Parameters Explained

In the above command, it will copy all the files from \\OldSharedFolder\Data source shared folder to \\NewSharedFolder\Data destination shared folder.


Example 2:

Robocopy C:\MyData M:\ExternalDrive\BackupData

Parameters Explained

In the above command, it will copy all the files from C:\MyData source folder to C:\MyData destination external drive folder.

Example 3:

Robocopy C:\MyData \\FileServer\MyDataBackup *.doc *.docx *.xls *.xlsx

Parameters Explained

Copy all .doc, .docx, .xls and .xlxs files from C:\MyData local Folder to \\FileServer\MyDataBackup Shared folder. Note: You can have multiple file extensions, please provide Space between two extensions.

Example 4:

Robocopy \\10.0.1.5\SharedFolder_Admin D:\SharedFolder_Admin /E /SEC /R:1 /W:1 /LOG+:c:\Robocopylog.txt /TEE

Parameters Explained

Command will copy all the files from source shared folder “\\10.0.1.5\SharedFolder_Admin” to the “D:\SharedFolder_Admin” local destination Folder Path.

/E & /Sec – It will copy all the files and folders along with the Security permissions.

/R:1 & /W:1 - Only once it will retries on failed copies with wait time of 1 min.

/Log+ & /TEE- It will write everything into log file name C:\Robocopylog.txt in append mode. Also, display the same into the console window.

Example 5:

Robocopy \\SharedFolder\TempData \\BackupSharedFolder\Achival /move /minage:30

Parameters Explained

Above command will move all the Files and Folders from \\SharedFolder\TempData source folder to \\BackupSharedFolder\Achival folder which is older than 30 Days. (Note: If any file is open or locked move option will fail. Also, If no of days is < 1900 then you have to mention no of days, else you have to mention date in the format YYYYMMDD.)


Finally, you can try multiple switch combination to complete your work as per your environment. While copying a large volume of data, you'll get some errors. I will suggest, always enable activity logging. Robocopy can excellently log activities.

Robocopy is a very powerful tool for big size data migrations tasks. It keeps an eye on the two data sources in sync and keeps an eye on the activities using the built-in logging capabilities




#Robocopy #FileTransfer #DeletefilesafterNDays #FileServerMigration #DataMigration #CommandLineTool #WindowsCommandTool #FileCopyTool #BackupTool

0 views