Advertisement
iTA360

Backup Robocopy

May 9th, 2022 (edited)
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.87 KB | None | 0 0
  1. robocopy
  2. Article
  3. 06/29/2021
  4. 8 minutes to read
  5. 16 contributors
  6.  
  7.  
  8. Copies file data from one location to another.
  9.  
  10. Syntax
  11.  
  12. Copy
  13. robocopy <source> <destination> [<file>[ ...]] [<options>]
  14. For example, to copy a file named yearly-report.mov from c:\reports to a file share \\marketing\videos while enabling multi-threading for higher performance (with the /mt parameter) and the ability to restart the transfer in case it's interrupted (with the /z parameter), type:
  15.  
  16. dos
  17.  
  18. Copy
  19. robocopy c:\reports '\\marketing\videos' yearly-report.mov /mt /z
  20. Parameters
  21. Parameter Description
  22. <source> Specifies the path to the source directory.
  23. <destination> Specifies the path to the destination directory.
  24. <file> Specifies the file or files to be copied. Wildcard characters (* or ?) are supported. If you don't specify this parameter, *.* is used as the default value.
  25. <options> Specifies the options to use with the robocopy command, including copy, file, retry, logging, and job options.
  26. Copy options
  27. Option Description
  28. /s Copies subdirectories. This option automatically excludes empty directories.
  29. /e Copies subdirectories. This option automatically includes empty directories.
  30. /lev:<n> Copies only the top n levels of the source directory tree.
  31. /z Copies files in restartable mode. In restartable mode, should a file copy be interrupted, Robocopy can pick up where it left off rather than re-copying the entire file.
  32. /b Copies files in backup mode. Backup mode allows Robocopy to override file and folder permission settings (ACLs). This allows you to copy files you might otherwise not have access to, assuming it's being run under an account with sufficient privileges.
  33. /zb Copies files in restartable mode. If file access is denied, switches to backup mode.
  34. /j Copies using unbuffered I/O (recommended for large files).
  35. /efsraw Copies all encrypted files in EFS RAW mode.
  36. /copy:<copyflags> Specifies which file properties to copy. The valid values for this option are:
  37. D - Data
  38. A - Attributes
  39. T - Time stamps
  40. S - NTFS access control list (ACL)
  41. O - Owner information
  42. U - Auditing information
  43. The default value for this option is DAT (data, attributes, and time stamps).
  44. /dcopy:<copyflags> Specifies what to copy in directories. The valid values for this option are:
  45. D - Data
  46. A - Attributes
  47. T - Time stamps
  48. The default value for this option is DA (data and attributes).
  49. /sec Copies files with security (equivalent to /copy:DATS).
  50. /copyall Copies all file information (equivalent to /copy:DATSOU).
  51. /nocopy Copies no file information (useful with /purge).
  52. /secfix Fixes file security on all files, even skipped ones.
  53. /timfix Fixes file times on all files, even skipped ones.
  54. /purge Deletes destination files and directories that no longer exist in the source. Using this option with the /e option and a destination directory, allows the destination directory security settings to not be overwritten.
  55. /mir Mirrors a directory tree (equivalent to /e plus /purge). Using this option with the /e option and a destination directory, overwrites the destination directory security settings.
  56. /mov Moves files, and deletes them from the source after they are copied.
  57. /move Moves files and directories, and deletes them from the source after they are copied.
  58. /a+:[RASHCNET] Adds the specified attributes to copied files. The valid values for this option are:
  59. R - Read only
  60. A - Archive
  61. S - System
  62. H - Hidden
  63. C - Compressed
  64. N - Not content indexed
  65. E - Encrypted
  66. T - Temporary
  67. /a-:[RASHCNET] Removes the specified attributes from copied files. The valid values for this option are:
  68. R - Read only
  69. A - Archive
  70. S - System
  71. H - Hidden
  72. C - Compressed
  73. N - Not content indexed
  74. E - Encrypted
  75. T - Temporary
  76. /create Creates a directory tree and zero-length files only.
  77. /fat Creates destination files by using 8.3 character-length FAT file names only.
  78. /256 Turns off support for paths longer than 256 characters.
  79. /mon:<n> Monitors the source, and runs again when more than n changes are detected.
  80. /mot:<m> Monitors the source, and runs again in m minutes, if changes are detected.
  81. /MT[:n] Creates multi-threaded copies with n threads. n must be an integer between 1 and 128. The default value for n is 8. For better performance, redirect your output using /log option.
  82. The /mt parameter can't be used with the /ipg and /efsraw parameters.
  83.  
  84. /rh:hhmm-hhmm Specifies run times when new copies may be started.
  85. /pf Checks run times on a per-file (not per-pass) basis.
  86. /ipg:n Specifies the inter-packet gap to free bandwidth on slow lines.
  87. /sl Don't follow symbolic links and instead create a copy of the link.
  88. /nodcopy Copies no directory info (the default /dcopy:DA is done).
  89. /nooffload Copies files without using the Windows Copy Offload mechanism.
  90. /compress Requests network compression during file transfer, if applicable.
  91. Important
  92.  
  93. When using the /secfix copy option, specify the type of security information you want to copy, using one of these additional copy options:
  94.  
  95. /copyall
  96. /copy:o
  97. /copy:s
  98. /copy:u
  99. /sec
  100. File selection options
  101. Option Description
  102. /a Copies only files for which the Archive attribute is set.
  103. /m Copies only files for which the Archive attribute is set, and resets the Archive attribute.
  104. /ia:[RASHCNETO] Includes only files for which any of the specified attributes are set. The valid values for this option are:
  105. R - Read only
  106. A - Archive
  107. S - System
  108. H - Hidden
  109. C - Compressed
  110. N - Not content indexed
  111. E - Encrypted
  112. T - Temporary
  113. O - Offline
  114. /xa:[RASHCNETO] Excludes files for which any of the specified attributes are set. The valid values for this option are:
  115. R - Read only
  116. A - Archive
  117. S - System
  118. H - Hidden
  119. C - Compressed
  120. N - Not content indexed
  121. E - Encrypted
  122. T - Temporary
  123. O - Offline
  124. /xf <filename>[ ...] Excludes files that match the specified names or paths. Wildcard characters (* and ?) are supported.
  125. /xd <directory>[ ...] Excludes directories that match the specified names and paths.
  126. /xc Excludes changed files.
  127. /xn Excludes newer files.
  128. /xo Excludes older files.
  129. /xx Excludes extra files and directories.
  130. /xl Excludes "lonely" files and directories.
  131. /im Include modified files (differing change times).
  132. /is Includes the same files.
  133. /it Includes tweaked files.
  134. /xc Excludes existing files with the same timestamp, but different file sizes.
  135. /xn Excludes existing files newer than the copy in the source directory.
  136. /xo Excludes existing files older than the copy in the source directory.
  137. /xx Excludes extra files and directories present in the destination but not the source. Excluding extra files will not delete files from the destination.
  138. /xl Excludes "lonely" files and directories present in the source but not the destination. Excluding lonely files prevents any new files from being added to the destination.
  139. /is Includes the same files. Same files are identical in name, size, times, and all attributes.
  140. /it Includes "tweaked" files. Tweaked files have the same name, size, and times, but different attributes.
  141. /max:<n> Specifies the maximum file size (to exclude files bigger than n bytes).
  142. /min:<n> Specifies the minimum file size (to exclude files smaller than n bytes).
  143. /maxage:<n> Specifies the maximum file age (to exclude files older than n days or date).
  144. /minage:<n> Specifies the minimum file age (exclude files newer than n days or date).
  145. /maxlad:<n> Specifies the maximum last access date (excludes files unused since n).
  146. /minlad:<n> Specifies the minimum last access date (excludes files used since n) If n is less than 1900, n specifies the number of days. Otherwise, n specifies a date in the format YYYYMMDD.
  147. /xj Excludes junction points, which are normally included by default.
  148. /fft Assumes FAT file times (two-second precision).
  149. /dst Compensates for one-hour DST time differences.
  150. /xjd Excludes junction points for directories.
  151. /xjf Excludes junction points for files.
  152. Retry options
  153. Option Description
  154. /r:<n> Specifies the number of retries on failed copies. The default value of n is 1,000,000 (one million retries).
  155. /w:<n> Specifies the wait time between retries, in seconds. The default value of n is 30 (wait time 30 seconds).
  156. /reg Saves the values specified in the /r and /w options as default settings in the registry.
  157. /tbd Specifies that the system will wait for share names to be defined (retry error 67).
  158. Logging options
  159. Option Description
  160. /l Specifies that files are to be listed only (and not copied, deleted, or time stamped).
  161. /x Reports all extra files, not just those that are selected.
  162. /v Produces verbose output, and shows all skipped files.
  163. /ts Includes source file time stamps in the output.
  164. /fp Includes the full path names of the files in the output.
  165. /bytes Prints sizes, as bytes.
  166. /ns Specifies that file sizes are not to be logged.
  167. /nc Specifies that file classes are not to be logged.
  168. /nfl Specifies that file names are not to be logged.
  169. /ndl Specifies that directory names are not to be logged.
  170. /np Specifies that the progress of the copying operation (the number of files or directories copied so far) will not be displayed.
  171. /eta Shows the estimated time of arrival (ETA) of the copied files.
  172. /log:<logfile> Writes the status output to the log file (overwrites the existing log file).
  173. /log+:<logfile> Writes the status output to the log file (appends the output to the existing log file).
  174. /unicode Displays the status output as Unicode text.
  175. /unilog:<logfile> Writes the status output to the log file as Unicode text (overwrites the existing log file).
  176. /unilog+:<logfile> Writes the status output to the log file as Unicode text (appends the output to the existing log file).
  177. /tee Writes the status output to the console window, as well as to the log file.
  178. /njh Specifies that there is no job header.
  179. /njs Specifies that there is no job summary.
  180. Job options
  181. Option Description
  182. /job:<jobname> Specifies that parameters are to be derived from the named job file.
  183. /save:<jobname> Specifies that parameters are to be saved to the named job file.
  184. /quit Quits after processing command line (to view parameters).
  185. /nosd Indicates that no source directory is specified.
  186. /nodd Indicates that no destination directory is specified.
  187. /if Includes the specified files.
  188. Exit (return) codes
  189. Value Description
  190. 0 No files were copied. No failure was encountered. No files were mismatched. The files already exist in the destination directory; therefore, the copy operation was skipped.
  191. 1 All files were copied successfully.
  192. 2 There are some additional files in the destination directory that are not present in the source directory. No files were copied.
  193. 3 Some files were copied. Additional files were present. No failure was encountered.
  194. 5 Some files were copied. Some files were mismatched. No failure was encountered.
  195. 6 Additional files and mismatched files exist. No files were copied and no failures were encountered. This means that the files already exist in the destination directory.
  196. 7 Files were copied, a file mismatch was present, and additional files were present.
  197. 8 Several files did not copy.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement