Robocopy Syntax. Backup data using the robocopy utility. Robocopy copy options

IN Windows Server The 2008 R2 Microsoft has improved significantly and improved the backup system (both block and file). The following functions appeared:

  • Improved backup support at file level:nowyou can select specific folders and files that need to be included / excluded from backup.
  • Improved backup support over the network: Now it is possible to back up to the NAS device with a running access to the SAMBA files (backup at the file level is not fully supported). Incremental copying is also supported, but only if the VVS service works on the recipient.

However, due to the presence of a number of restrictions in the embedded procedure for performing a backup in Windows Server 2008 R2 Microsoft, you can use third-party utilities, special programs for backup, or utility robocopy..

Backup With robocopy

Robocopy is decrypted as "Robust File Copy", it is a utility command line To replicate directories, this utility In many respects, it looks like a UNIX - XCOPY command. The main advantage of the team is that it will allow you to copy / move only those files that have been changed, which allows you to implement the incremental backup function.

The syntax of the Robocopy command can be viewed by opening the command line and typing:

robocopy. /?

For example, we want to copy all new photos on the NAS network drive. In our example, we must specify a source folder, destination folder and command options:

robocopy "E: \\ Documents" "\\\\ NAS \\ Backup \\ Documents" / mir

The "/ mir" parameters mean that you need to perform a mirror copy, i.e. If I delete the photo in the source directory, it will be removed in my backup.

Another convenient Robocopy feature is the possibility of postponed copying, i.e. If the source folder or destination is not available, the copy will be executed later. By default, waiting time is 30 seconds, after which there will be another 1000000 travelers to copy files, if we want, for example, perform re-copying after 15 seconds and repeat it only 5 times, you can use such a command:

robocopy "E: \\ Documents" "\\\\ NAS \\ Backup \\ Documents" / MIR / R: 5 / W: 15

Even more option:

robocopy "E: \\ Documents" "\\\\ NAS \\ Backup \\ Documents" / Z / MIR / R: 5 / W: 15 / V / TS / FP / NP /LOG /:"C:\\Nassync.log "

The above Robocopy parameters suggest that it is necessary to make a detailed output of execution results (/ V), output the time label (/ TS), the full path (/ FP), not shown the progress scale (/ NP), and display the results into the log file ( / Log +). For NAS that do not support file nTFS systemYou must specify the / FFT parameter.

Backup scheduling

In order to perform regular backups, you can use windows schedulerTaskScheduler. Run the scheduler, create a new task Create.Basic.Task, in the wizard Specify the name of the task (for example, Backup) and click Next. On the screen Trigger., Indicate how often you need to back up. On the tab Action. We specify that we want to run the program, click Next. Next, specify the name of the program, you can simply dial robocopy., or specify the full path to the program C: \\Windows \\System32 \\robocopy.eXE. In the window with the parameters ( Add.arguments (optional)) We must specify the arguments of the Robocopy command.

Press Next and FINISH.

In order to verify the correct operation of the task, let's go to the planner, we will find our task in it, right-click Click on it and choose RUN.. After the task is completed, its status can be found in Last.RUN.RESULT.

Examples of using Robocopy

Consider various scenarios and parameters of using Robocopy.

1. Copy files changed over the past 5 days (excluding today).

robocopy "E: \\ Documents" "\\\\ NAS \\ Backup \\ Documents" / Maxage: 5 / MINAGE: 1

2. Move all files:

robocopy "E: \\ Documents" "\\\\ NAS \\ Backup \\ Documents" / MOVE / E

3. Copy files with the exception of hidden (/ xa: h):

robocopy "E: \\ Documents" "\\\\ NAS \\ Backup \\ Documents" / E / XA: H

or, with the exception of read-only (/ Ia: RS):

robocopy "E: \\ Documents" "\\\\ NAS \\ Backup \\ Documents" / IA: RS

When copying, you can also change the file attributes, using the A + option (add attribute) Option (Delete attribute). Copy all files and set the read-only attribute:

robocopy "E: \\ Documents" "\\\\ NAS \\ Backup \\ Documents" / E / A +: R

4. Copy all files by template (extension), empty folders do not copy:

robocopy "E: \\ Documents" "\\\\ NAS \\ Backup \\ Documents" * .doc * .ppt / s

5. Copy all files size from 1000 to 60,000 bytes:

robocopy "E: \\ Documents" "\\\\ NAS \\ Backup \\ Documents" / E / MAX: 60000 / MIN: 1000

6. Exclude from copying the APPDATA folder (/ xD AppData):

Robocopy "C: \\ Users \\ Administrator" "\\\\ NAS \\ Backup \\ Administrator" / MIR / XA: SH / XD APPDATA / XJD

7. Create 32 streams (/ MT: 32) File Copy:

Robocopy "C: \\ Users \\ Administrator" \\\\ NAS \\ BACKUP \\ ADMINISTRATOR / MIR / XA: SH / XD AppData / XJD / R: 5 / W: 15 / MT: 32

In the example, we use the / mt [: n] option, where n is a number from 1 to 128, which determines the number of streams. By default, if the / MT parameter is not specified, 8 threads are used.

Robocopy (Robust File Copy) The command line utility that comes with Windows Vista. and newer versions of Windows. In older windows versions She was part of Windows Resource Kit Tools. Unlike the usual COPY command, Robocopy is created for more reliable copying and mirroring. With a member of strings, attributes, user information, TimesTampav copied objects.

Robocopy syntax:

Robocopy Source Destination
  • source - Directory from where we will copy. May be a network path.
  • destination - directory where you copy. Local or network path.
  • - Files that need to be copied. WILDCARD Symbols can be used (* or?). If the parameter is not specified, then the default is *. *

Examples of using the Robocopy command

Robocopy C: \\ SRC C: \\ DST * .txt

In this example, all files will be copied from the C: \\ SRC directory in the C: \\ DST directory.

Robocopy C: \\ SRC C: \\ DST / E

Copy all files, including empty.

Robocopy C: \\ SRC C: \\ DST / MIR

Make a mirror. Use with caution because From C: \\ DST all files that are not in C: \\ SRC will be deleted

Robocopy Robocopy \\\\ Computer \\ SRC C: \\ DST

File source on another computer online.

Description of all options and parameters

Robocopy copy options

Description

/ S. Copy subdirectory. Empty directories are skipped.
/ E. Copy subdirectory, including empty.
/ Lev: Copy only upper N. Directories tree levels.
/ Z. Copy files in restart mode.
/ B. Copy files in backup mode.
/ ZB. Restart is used. If access is prohibited, the backup mode is used.
/ EFSRAW

Copy encrypted files in EFS RAW mode.

/ Copy:

Specify which file properties will be copied. Correct options for this option:

  • D Data.
  • A attributes.
  • T Time Stamp
  • S NTFS ACCESS CONTROL LIST (ACL)
  • O Owner Information
  • U auditing information

The default value of DATA (DATA, Attributes, and Time Stamps).

/ DCOPY: T Copy TimesTampa directory.
/ sec. Copy Files with Security (Equivalent / Copy: DAT).
/ Copyall Copy all information on files (equivalent / Copy: Datsou).
/ Nocopy. Do not copy information on files (useful with / PURGE).
/ SecFix. Fix Security on all files, even missed.
/ timfix. Fix the time on all files, even missed.
/ Purge. Delete files in the destination folder, which are no longer in the source folder.
/ mir. Mirroring directories (equivalent to two options / E with / Purge).
/ MOV. Move files. Those. After copying, source will be removed.
/ Move. Move files and directories. Sources will be deleted.
/ a +: Add attributes to copied files. ADDS The Specified Attributes to Copied Files.
/ A-: Delete attributes from copied files.
/ Create. Create a directory tree and zero-size files.
/ Fat. Create files with names in 8.3 format as in Fat.
/256 Disable support for very long paths (which are more than 256 characters).
/ MON: Monitor the source folder and if you find more than N. Changes will start copying changed files. Read more: Planner in Robocopy.
/ Mot: Monitor the source folder, searches for changes every M. minutes and starts copying if there were changes. Read more: Planner in Robocopy.
/ RH: HHMM-HHMM Specifies the time when the scheduled copy is started. Read more: Planner in Robocopy.
/ Pf. CHECKS RUN TIMES ON PER-FILE (NOT PER-PASS) BASIS.
/ IPG: N Specifies The Inter-Packet Gap to Free Bandwidth on Slow Lines.
/ SL. Copy symbolic links, instead of a real file.

File selection options

/ A. Copy only those files that have an archive attribute.
/ M. Copy only those files that have an archive attribute, and then reset this attribute.
/ IA: Copy only those files that have specified attributes.
/ XA: Do not copy those files that have specified attributes.
/ XF. [ ...]

Do not copy those files that name or path are similar to the specified. In the file name, you can use "*" and "?".

/ xd. [ ...] Do not copy those directories in which the name or path is similar to the specified. In the name of the directory you can use "*" and "?".
/ xct. Do not copy changed files.
/ XN. Do not copy new files.
/ XO. Do not copy old files.
/ XX Do not copy those files and folders that already exist in the destination folder.
/ XL EXCLUDES "LONELY" Files and Directories.
/ IS. Includes The Same Files.
/ IT. Includes "tweaked" Files.
/ MAX: Do not copy files that are more than more than N. byte.
/ min: Do not copy files that are less than less than N. byte.
/ Maxage: Do not copy files that old N. days.
/ MINAGE: Minimum age files N. days.
/ Maxlad: Do not copy those files that were not used starting from the date N..
/ MINLAD: Copy files that were used to a specific date. If a N. Less than 1900, then these days. Otherwise, this year in yyyymmdd format.
/ XJ. Do not copy Junction Points. By default, they are copied.
/ FFT. Assumes Fat File Times (Two Second Precision).
/ dst. Compensates for One-Hour Dst Time Differences.
/ XJD. Do not copy Junction Points for directories.
/ XJF. Do not copy Junction Points for files.

Repeat options

Laigne Options

/ L. Shows the list of files that are selected for processing, but the copy itself, removal, etc. Will not run.
/ X. Reports everything additional files, not just those chosen.
/ V. Chatter mode. Show also missed files.
/ TS.

Shows the timestamps of files.

/ FP. Show full paths to files.
/ Bytes. Show file size in bytes.
/ NS. Indicates that file sizes are not logged.
/ NC. Indicates that file classes should not be login.
/ NFL File names will not be login.
/ NDL. Director names will not be login.
/ NP. Copy progress will not be displayed. Those. Number of files and directories.
/ ETA Shows an approximate time of arrival of copied files.
/ Log: Logging into a file. If such a log file is already there, it will be overwritten.
/ log +: Logging into a file. If such a log file is already there, the data will be added to it.
/ Unicode. Display status in unicode.
/ Unilog: Logging to a file in Unicode format. If such a log file is already there, it will be overwritten.
/ Unilog +: Logging to a file in Unicode format. If such a log file is already there, the data will be added to it.
/ Tee. Logging both in the file and in the console.
/ NJH Indicates that there is no title of the task.
/ NJS. Indicates that there is no resume work.

Each Wintel administrator is familiar with the Robocopy utility. Since the time of Windows NT4, it entered the Resource Kit, and starting with Windows Vista, the operating system.
Why do I need robocopy? To copy files. Many files. We mainly use it to migrate file servers or backup.
There are many interesting options for migrating file servers, for example, using DFS-R. But there is nothing easier and more reliable

Robocopy \\\\ SERV \\ D $ F: \\ / E / COPYALL / ZB / MT: 8 / R: 1 / W: 5 / V / TS / FP / ETA / TEE / TS / FP / ETA / TEE /Log.Txt

In the final, you can close user access to the resource and create an incremental copy by adding a key / mir.
But is it good robocopy? Is it good enough to trust her the migration of the most important files?

One fine Saturday morning I migrated file server. Employees at work did not turn out. The first copy was made yesterday, it remained only to make increment and update links to DFS.
I launched Robocopy, looked at the magazine, and for reinsurance, before switching, I decided to see how many files and folders in the source and end file resource. Numbers did not come together. Suddenly.

But why? I saw such a result for the first time. Did I do something wrong? Someone from employees still changed the files while incremental copy? Key / MIR has failed? Some files are missing? Empty? With Access Denied? Damaged?

Well, turn off network access And again copy files. Do not converge! We try without / mir. The same result.
I was in bewilderment. Fifteen years I trusted Robocopy at 100%, and today, for the first time, she failed. Some files are simply not at the destination! Just impossible to believe it.

Let's calculate the files differently. Swing the FileList utility and make the listing of files in the source and final folder. And here the number of files coincided. Surprisingly.

And what if it's not in Robocopy? What if Windows Explorer What does it consider wrong? Maybe in Windows Server 2008 R2 bad Explorer, and in Windows Server 2012 R2 good? I opened the properties of the local and target folder on the source windows server Server 2008 R2. The number of files did not coincide. We hope that everything is fixed in Windows Server 2012 R2. Open the properties of the folders on the new server ... and ...

Not only the number of files in the source and final folder did not coincide. The number of files differed from filmed on Windows Server 2008 R2. Black outdoor magic.

And at that moment (finally) it was concerned about me. It's not about robocopy, and not in versions explorer. Just Explorer can not (!) Read, and does not consider files and folders with names longer than 260 characters.

On the source server, the files were located along the path "F: \\ Office1". In the new - "U: \\ SharedFiles \\ Office1".
Just because of the "SharedFiles" subfolder, the names of some files and folders were longer than 255 characters. For Robocopy, they did not compose them to copy them. FileList easily calculated them. And only Explorer missed such files when counting.

By making Subst n: U: \\ SharedFiles and calculating the number of files in F: \\ Office1 on the source server and N: \\ Office1 on the target, the number of files coincided.

Robocopy can be trusted.

Upd.: How to correct in the comments, nevertheless not 255, but

To create accurate duplicates of all file required in folder user profile (C: \\ Users \\ your name) by multi-threaded copying.

Why use Robocopy?

If you are a conscious user, you are probably so regularly creating an image hard disk and network data using the "Backup and Restore" (Backup and Restore) of Windows 7. However, it will not prevent the creation and one more backup - just in case. This can be done manually by dragging the necessary files On external hDDBut if there are too many of them, the process can delay.

The Robocopy utility allows you to use more eighty command-line switches to create an effective backup script. To facilitate your task, I will explain how to use the capabilities of the utility to create a mirror copy of all files in the folder of your profile (C: \\ users \\ your name).

Drawing up a team

As an example, I will make a command to copy my contents. custom folder "C: \\ Users \\ Greg Shultz" in the "TheBackup" folder on an external hard disk mounted under the Literary "G" (you, of course, replace the names and addresses on your own). The team will start like this:

Robocopy "C: \\ Users \\ Greg SHULTZ" "G: \\ TheBackup"


I want to copy all the folders, even empty, because they can come in handy for future files. At the same time, I want to exclude from copying files that have already deleted. You can use for this switches / s and / Purge, but I prefer to do with one switch to perform both tasks - / mir. Now the team looks like this:

Robocopy "C: \\ Users \\ Greg SHULTZ" "G: \\ TheBackup" / mir


In the folder "C: \\ Users \\ Greg Shultz" there are several hidden system files and folders that I am not going to copy - for example, "ntuser.dat" and "AppData". In addition, there are several connection points in the profile folder, which are tied to it. system folders - For example, "Cookies" and "Sendto".

To exclude from copy hidden system filesI use the switch / XA: SH, and so as not to copy the "APPDATA" folder with all contents - switch / xD. Finally, the switch / XJD allows you to exclude all connectivity points. As a result, the team now looks like this:

Robocopy "C: \\ Users \\ Greg SHULTZ" "G: \\ TheBackup" / MIR / XA: SH / XD AppData / XJD


One of the most useful features of the robocopy is connected with how the utility processes open files. If such a file is detected, the program suspends copying and waits until it closes. Every 30 seconds robocopy tries to resume copying. By default, a million attempt is provided (I'm not kidding!), But in this case, the copying is not destined at all, so the number of attempts is better to reduce.

This uses a switch / r, and change the interval between attempts with the switch / w. I will reduce the number of attempts to five, and the time interval between them is up to 15 seconds. Then Robocopy will be able to resume copying by waiting for some time. Now the team looks like this:

Robocopy "C: \\ Users \\ Greg Shultz" "G: \\ TheBackup" / MIR / XA: SH / XD AppData / XJD / R: 5 / W: 15


Now you can add a multi-threading / mt [: n] switch to the command, where n is the number of streams from 1 to 128. The value N can not be indicated, and to do with the switch / MT. In this case, eight streams will be used. I prefer 32 threads. Please note that multi-threaded copying is not compatible with switches / IPG and / EFSRAW. So, a new team:

Robocopy "C: \\ Users \\ Greg SHULTZ" "G: \\ TheBackup" / MIR / XA: SH / XD AppData / XJD / R: 5 / W: 15 / MT: 32


Like all command line utilities, Robocopy constantly informs the user about the operation status, but much more convenient to save this data in the report form. To get a full picture, I will use the switch / V, but information about the progress of copying each separate file. I do not need, so I will add a switch / NP to the command. The report file is created using the / log switch and overwrites each time the utility is next. The final team looks like this:

Robocopy "C: \\ Users \\ Greg SHULTZ" "G: \\ TheBackup" / MIR / XA: SH / XD AppData / XJD / R: 5 / W: 15 / MT: 32 / V / NP /Log :Backup.log


Creation and use of the script

Now that you know how to use switches, make the command you need in a notebook (notePAD) and save the file named "robocopybackup.cmd". So that the open script and report files do not interfere with copying, I created the C: \\ BackupTool folder in the root directory and saved them there.

The report file will be saved to the same directory after each start of the utility. Although it is simple text file, he may be too voluminous for notepad, so to open it stands in some other text processor - For example, in WordPad.

Now, when you need to create an additional backup, just run the file "robocopybackup.cmd" double-clickAnd at the end of the operation, examine the report file "backup.log". Via

Good day. Dear readers and guests, large IT blog on the ranking Yandex.Randar 2500 place, among all the sites of Russia. Last time, we solved the problem with the failure of the device's request. Today I do not want to consider new mistakes, but I will share my experience use Robocopy utilities, I will give examples of use, talk about the parameters of the utility and show how robocopy use graphic interface (GUI). This program is simply obliged to use each system administrator, well, or at least know. About her existence, personally, it is in a honorable place in my set of system engineer.

What is Robocopy (Robust File Copy Utility)

Utility robocopy (Robust File Copy Utility) is a specialized agent, in whose tasks thin tuning The copying, synchronization, deletion and transfer of files and folders, between the disks of the computer, computers, network balls and forests, with the preservation of attributes, permissions and much more.

Robocopy at the expense of its algorithms and multithreading allows you to copy or synchronize some file resources with other ten times faster than the usual copy of Windows Explorer.

This tool is very often used in the tasks of the system administrator, by transferring the network ball and file resources, and in data synchronization scenarios.

If you turn to Wikipedia (https://ru.wikipedia.org/wiki/robocopy), then there you will find that it was created as a means of replication and walked as part of such a well-known tool complex as Windows Resource Kit.

Versions of the robocopy utility

The first version of Robocopy appeared in 1997 as part of Windows Resource Kit tools. Currently the latest version is 10.0.17763.1 in the part of Windows 10 1809, I corrected a sign in Wikipedia (https://en.wikipedia.org/wiki/robocopy)

Where is Robocopy in the system?

The main executable file robocopy.exe is located on the path C: \\ Windows \\ System32. The utility is very compact and weighs only 132 kilobytes, but it does not reduce its power and functional.

Where to download the windows robocopy utility

Download Robocopy Gui Utility Ver. 3.1 can be from the official site https://docs.microsoft.com/en-us/previous-version/technet-magazine/cc160891(v\u003dmsdn.10) or I have a link with mail clouds

After downloading the Robocopy Gui Utility ver. 3.1, we need to install it. Run the executable file. We agree with the license agreement.

The utility will offer you to specify the directory where the files will be retrieved.

We agree with the extraction.

As a result, you will receive this file structure. Run Setup.exe.

You will have a trivial GUI interface installation wizard for Robocopy. Click Next.

Accept license agreement "I GREE"

Indicate whether the utility will be installed only for you or for all.

Installing the graphical interface for Robocopy completed.

You will appear on the desktop Microsoft Robocopy GUI label. We launch it and see what this utility represents.

Review Robocopy Gui Utility Ver. 3.1

Let me show a break, which represents this program. The graphical interface itself is very simple and should be. On the first tab, you will see two actions:

  1. First, it is necessary through "Source Path to choose what we will copy"
  2. Second Action, this is in "Target Path We ask where we will carry data, if you wish, you can mount network Disk, through the "Map Drive" item "

On the "Copy Options" tab, you will see more familiar parameters of using Robocopy, there are also keys / sec for transferring rights and command / MOVE that we used to cut files and much more. Immediately you set the number of copy streams.

The DRIVE MAPPING tab will help attach a network drive, here you specify an IP address or DNS name Servers, and connection credentials.

The "Filters" tab will allow you to specify that it is necessary to transfer and make filtering, for example, not to transfer the length of the length of which in the name is more than 256 characters, or only TXT files.

The "Logging" tab specifies the logging parameters of your task.

The Monitoring Options tab will be useful for monitoring the copy source, in case of problems, everything can be identified and restart.