{"id":1360,"date":"2015-02-02T12:29:28","date_gmt":"2015-02-02T12:29:28","guid":{"rendered":"http:\/\/stevenwhiting.com\/blog\/?p=1360"},"modified":"2015-02-02T12:31:10","modified_gmt":"2015-02-02T12:31:10","slug":"1360","status":"publish","type":"post","link":"https:\/\/stevenwhiting.com\/blog\/?p=1360","title":{"rendered":""},"content":{"rendered":"<p><a href=\"http:\/\/ss64.com\/nt\/robocopy.html\" target=\"_blank\">http:\/\/ss64.com\/nt\/robocopy.html<\/a><\/p>\n<blockquote>\n<h1>ROBOCOPY.exe (<a href=\"http:\/\/ss64.com\/links\/windows.html#kits\">XP Resource Kit<\/a>\/Standard Windows 7 command)<\/h1>\n<p>Robust File and Folder Copy.<br \/>\nBy default Robocopy will only copy a file if the source and destination have different time stamps or different file sizes.<\/p>\n<pre>Syntax\r\n      ROBOCOPY <i>Source_folder Destination_folder<\/i> [<i>files_to_copy<\/i>] [<i>options<\/i>]\r\n\r\nKey\r\n   file(s)_to_copy : A list of files or a <a href=\"http:\/\/ss64.com\/nt\/syntax-wildcards.html\">wildcard<\/a>.\r\n                          (defaults to copying *.*)\r\n\r\n  <i>Source options<\/i>\r\n                \/S : Copy Subfolders.\r\n                \/E : Copy Subfolders, including Empty Subfolders.\r\n \/COPY:<i>copyflag<\/i>[<i>s<\/i>] : What to COPY (default is \/COPY:DAT)\r\n                      (copyflags : <b>D<\/b>=Data, <b>A<\/b>=Attributes, <b>T<\/b>=Timestamps\r\n                       <b>S<\/b>=Security=NTFS ACLs, <b>O<\/b>=Owner info, <b>U<\/b>=aUditing info).\r\n              \/SEC : Copy files with SECurity (equivalent to \/COPY:DATS).\r\n          \/DCOPY:T : Copy Directory Timestamps. ##\r\n          \/COPYALL : Copy ALL file info (equivalent to \/COPY:DATSOU).\r\n           \/NOCOPY : Copy NO file info (useful with \/PURGE).\r\n\r\n                \/A : Copy only files with the Archive attribute set.\r\n                \/M : like \/A, but remove Archive attribute from source files.\r\n            \/LEV:<i>n<\/i> : Only copy the top <i>n<\/i> LEVels of the source tree.\r\n\r\n         \/MAXAGE:<i>n<\/i> : MAXimum file AGE - exclude files older than <i>n<\/i> days\/date.\r\n         \/MINAGE:<i>n<\/i> : MINimum file AGE - exclude files newer than <i>n<\/i> days\/date.\r\n                     (If <i>n<\/i> &lt; 1900 then <i>n<\/i> = no of days, else <i>n<\/i> = YYYYMMDD date).\r\n\r\n              \/FFT : Assume FAT File Times (2-second date\/time granularity).\r\n              \/256 : Turn off very long path (&gt; 256 characters) support.\r\n\r\n   <i>Copy options<\/i>\r\n                \/L : List only - don\u2019t copy, timestamp or delete any files.\r\n              \/MOV : MOVe files (delete from source after copying).\r\n             \/MOVE : Move files and dirs (delete from source after copying).\r\n\r\n                \/Z : Copy files in restartable mode (survive network glitch).\r\n                \/B : Copy files in Backup mode.\r\n               \/ZB : Use restartable mode; if access denied use Backup mode.\r\n            \/IPG:<i>n<\/i> : Inter-Packet Gap (ms), to free bandwidth on slow lines.\r\n\r\n              \/R:<i>n<\/i> : Number of Retries on failed copies - default is 1 million.\r\n              \/W:<i>n<\/i> : Wait time between retries - default is 30 seconds.\r\n              \/REG : Save \/R:n and \/W:n in the Registry as default settings.\r\n              \/TBD : Wait for sharenames To Be Defined (retry error 67).\r\n\r\n   <i>Destination options<\/i>\r\n\r\n    \/A+:[RASHCNET] : Set file Attribute(s) on destination files + add.\r\n    \/A-:[RASHCNET] : UnSet file Attribute(s) on destination files - remove.\r\n              \/FAT : Create destination files using 8.3 FAT file names only.\r\n\r\n           \/CREATE : CREATE directory tree structure + zero-length files only.\r\n              \/DST : Compensate for one-hour DST time differences ##\r\n            \/PURGE : Delete dest files\/folders that no longer exist in source.\r\n              \/MIR : MIRror a directory tree - equivalent to \/PURGE plus all subfolders (\/E)\r\n\r\n   <i>Logging options<\/i>\r\n                \/L : List only - don\u2019t copy, timestamp or delete any files.\r\n               \/NP : No Progress - don\u2019t display % copied.\r\n         \/LOG:<i>file<\/i> : Output status to LOG file (overwrite existing log).\r\n      \/UNILOG:<i>file<\/i> : Output status to Unicode Log file (overwrite) ##\r\n        \/LOG+:<i>file<\/i> : Output status to LOG file (append to existing log).\r\n     \/UNILOG+:<i>file<\/i> : Output status to Unicode Log file (append) ##\r\n               \/TS : Include Source file Time Stamps in the output.\r\n               \/FP : Include Full Pathname of files in the output.\r\n               \/NS : No Size - don\u2019t log file sizes.\r\n               \/NC : No Class - don\u2019t log file classes.\r\n              \/NFL : No File List - don\u2019t log file names.\r\n              \/NDL : No Directory List - don\u2019t log directory names.\r\n              \/TEE : Output to console window, as well as the log file.\r\n              \/NJH : No Job Header.\r\n              \/NJS : No Job Summary.\r\n\r\n <i>Repeated Copy Options<\/i>\r\n            \/MON:<i>n<\/i> : MONitor source; run again when more than <i>n<\/i> changes seen.\r\n            \/MOT:<i>m<\/i> : MOnitor source; run again in <i>m<\/i> minutes Time, if changed.\r\n\r\n     \/RH:<i>hhmm-hhmm<\/i> : Run Hours - times when new copies may be started.\r\n               \/PF : Check run hours on a Per File (not per pass) basis.\r\n\r\n <i>Job Options<\/i>\r\n      \/JOB:<i>jobname<\/i> : Take parameters from the named JOB file.\r\n     \/SAVE:<i>jobname<\/i> : SAVE parameters to the named job file\r\n             \/QUIT : QUIT after processing command line (to view parameters). \r\n             \/NOSD : NO Source Directory is specified.\r\n             \/NODD : NO Destination Directory is specified.\r\n               \/IF : Include the following Files.\r\n\r\n<i>Advanced options you'll probably never use<\/i>\r\n           \/EFSRAW : Copy any encrypted files using EFS RAW mode. ##\r\n           \/MT[:n] : Multithreaded copying, <i>n<\/i> = no. of threads to use (1-128) ###\r\n                     default = 8 threads, not compatible with \/IPG and \/EFSRAW\r\n                     The use of \/LOG is recommended for better performance.\r\n           \/SECFIX : FIX <a title=\"mirroring file permissions\" href=\"http:\/\/blogs.technet.com\/b\/filecab\/archive\/2008\/07\/31\/robocopy-mir-switch-mirroring-file-permissions.aspx\">file SECurity<\/a> on all files, even skipped files.\r\n           \/TIMFIX : FIX file TIMes on all files, even skipped files.\r\n\r\n               \/XO : eXclude Older - if destination file exists and is the same date\r\n                     or newer than the source - don\u2019t bother to overwrite it.\r\n         \/XC | \/XN : eXclude Changed | Newer files\r\n               \/XL : eXclude \"Lonely\" files and dirs (present in source but not destination)\r\n                     This will prevent any new files being added to the destination.\r\n               \/XX : eXclude \"eXtra\" files and dirs (present in destination but not source)\r\n                     This will prevent any deletions from the destination. (this is the default)\r\n\r\n\/XF <i>file<\/i> [<i>file<\/i>]... : eXclude Files matching given names\/paths\/wildcards.\r\n\/XD <i>dirs<\/i> [<i>dirs<\/i>]... : eXclude Directories matching given names\/paths.\r\n                     XF and XD can be used in combination  e.g.\r\n                     ROBOCOPY c:\\source d:\\dest \/XF *.doc *.xls \/XD c:\\unwanted \/S \r\n\r\n   \/IA:[RASHCNETO] : Include files with any of the given Attributes\r\n   \/XA:[RASHCNETO] : eXclude files with any of the given Attributes\r\n               \/IS : Include Same, overwrite files even if they are already the same.\r\n               \/IT : Include Tweaked files.\r\n               \/XJ : eXclude Junction points. (normally included by default).\r\n\r\n            \/MAX:<i>n<\/i> : MAXimum file size - exclude files bigger than <i>n<\/i> bytes.\r\n            \/MIN:<i>n<\/i> : MINimum file size - exclude files smaller than <i>n<\/i> bytes.\r\n         \/MAXLAD:<i>n<\/i> : MAXimum Last Access Date - exclude files unused since <i>n<\/i>.\r\n         \/MINLAD:<i>n<\/i> : MINimum Last Access Date - exclude files used since <i>n<\/i>.\r\n                     (If n &lt; 1900 then n = n days, else n = YYYYMMDD date).\r\n\r\n            \/BYTES : Print sizes as bytes.\r\n                \/X : Report all eXtra files, not just those selected &amp; copied.\r\n                \/V : Produce Verbose output log, showing skipped files.\r\n              \/ETA : Show Estimated Time of Arrival of copied files.<\/pre>\n<p>## = New Option in Vista (XP027) all other options are valid for the XP version of Robocopy (XP010)<br \/>\n### = New Option in Windows 7 and Windows 2008 R2<\/p>\n<p>Robocopy <a href=\"http:\/\/ss64.com\/nt\/robocopy-exit.html\">EXIT CODES<\/a><\/p>\n<p><b>File Attributes <\/b>[RASHCNETO]<\/p>\n<pre> R \u2013 Read only \r\n A \u2013 Archive \r\n S \u2013 System \r\n H \u2013 Hidden\r\n C \u2013 Compressed \r\n N \u2013 Not content indexed\r\n E \u2013 Encrypted \r\n T \u2013 Temporary\r\n O - Offline<\/pre>\n<p>If either the source or desination are a &#8220;quoted long foldername&#8221; <b>do not include a trailing backslash<\/b> as this will be treated as an escape character, i.e. <span class=\"code\">&#8220;C:\\some path\\&#8221;<\/span> will fail but <span class=\"code\">&#8220;C:\\some path\\\\&#8221;<\/span> or <span class=\"code\">&#8220;C:\\some path\\.&#8221;<\/span> or <span class=\"code\">&#8220;C:\\some path&#8221;<\/span> will work.<\/p>\n<p>By copying only the files that have changed, robocopy can be used to backup very large volumes.<\/p>\n<p>ROBOCOPY will accept UNC pathnames including UNC pathnames over 256 characters long.<\/p>\n<p><span class=\"code\">\/REG<\/span> Writes to the registry at <span class=\"code\">HKCU\\Software\\Microsoft\\ResKit\\Robocopy<\/span><\/p>\n<p><span class=\"code\">\/XX<\/span> (exclude extra) If used in conjunction with \/Purge or \/Mir, this switch will take precedence and prevent any files being deleted from the destination.<\/p>\n<p>To limit the network bandwidth used by robocopy, specify the Inter-Packet Gap parameter <span class=\"code\">\/IPG:<i>n<\/i> <\/span><br \/>\nThis will send packets of 64 KB each followed by a delay of <i>n<\/i> Milliseconds.<\/p>\n<p>Robocopy will fail to copy files that are locked by other users or applications, so limiting the number of retries with \/R:0 will speed up copying by skipping any in-use files. The Windows Volume Shadow Copy service is the only Windows subsystem that can copy open files. Robocopy does not use the Volume Shadow Copy service, but it can backup a volume shadow that has already been created with VSHADOW or <a href=\"http:\/\/ss64.com\/nt\/diskshadow.html\">DISKSHADOW<\/a>.<\/p>\n<p>All versions of Robocopy will copy security information (ACLs) for directories, version XP010 will <a href=\"http:\/\/blogs.technet.com\/b\/filecab\/archive\/2008\/07\/31\/robocopy-mir-switch-mirroring-file-permissions.aspx\">not copy file security changes<\/a> unless the file itself has also changed, this greatly improves performance.<\/p>\n<p><span class=\"code\">\/B<\/span> (backup mode) will allow Robocopy to override file and folder permission settings (ACLs).<\/p>\n<p><span class=\"code\">ERROR 5 (0x00000005) Changing File Attributes &#8230; Access is denied<\/span><br \/>\nThis error usually means that File\/Folder permissions or Share permissions on either the source or the destination are preventing the copy, either change the permissions or run the command in backup mode with <span class=\"code\">\/B<\/span>.<\/p>\n<p>To run ROBOCOPY under a non-administrator account will require <i><a href=\"http:\/\/ss64.com\/nt\/ntrights.html\">backup files<\/a><\/i><a href=\"http:\/\/ss64.com\/nt\/ntrights.html\"> privilege<\/a>, to copy security information <i><a href=\"http:\/\/ss64.com\/nt\/ntrights.html\">auditing<\/a><\/i><a href=\"http:\/\/ss64.com\/nt\/ntrights.html\"> privilege<\/a> is also required, plus of course you need at least <i>read <\/i>access to the files and folders.<\/p>\n<h2><a id=\"examples\"><\/a>Examples:<\/h2>\n<p>Simple copy of all files from one folder to another:<\/p>\n<pre>ROBOCOPY \\\\Server1\\reports \\\\Server2\\backup<\/pre>\n<p>Copy files including subfolders (even empty ones <span class=\"code\">\/E<\/span>)<br \/>\nIf this command is run repeatedly it will skip any files already in the destination, however it is not a true mirror as any files deleted from the source will remain in the destination.<\/p>\n<pre>ROBOCOPY \\\\Server1\\reports \\\\Server2\\backup *.* \/E<\/pre>\n<p>List files over 32 MBytes in size:<\/p>\n<pre>ROBOCOPY C:\\work \/MAX:33554432 \/L<\/pre>\n<p>Move files over 14 days old: (note the MOVE option will fail if any files are open and locked.)<\/p>\n<pre>ROBOCOPY C:\\work C:\\destination \/move \/minage:14<\/pre>\n<p>Backup a Server:<br \/>\nThe script below copies data from FileServ1 to FileServ2, the destination holds a full mirror along with file security info. When run regularly to synchronize the source and destination, robocopy will only copy those files that have changed (change in time stamp or size.)<\/p>\n<p class=\"code\">@ECHO OFF<br \/>\nSETLOCAL<\/p>\n<p class=\"code\">SET _source=\\\\FileServ1\\e$\\users<\/p>\n<p class=\"code\">SET _dest=\\\\FileServ2\\e$\\BackupUsers<\/p>\n<p class=\"code\">SET _what=\/COPYALL \/B \/SEC \/MIR<br \/>\n:: \/COPYALL :: COPY ALL file info<br \/>\n:: \/B :: copy files in Backup mode.<br \/>\n:: \/SEC :: copy files with SECurity<br \/>\n:: \/MIR :: MIRror a directory tree<\/p>\n<p>SET _options=\/R:0 \/W:0 \/LOG:MyLogfile.txt \/NFL \/NDL<br \/>\n:: \/R:n :: number of Retries<br \/>\n:: \/W:n :: Wait time between retries<br \/>\n:: \/LOG :: Output log file<br \/>\n:: \/NFL :: No file logging<br \/>\n:: \/NDL :: No dir logging<\/p>\n<p>ROBOCOPY %_source% %_dest% %_what% %_options%<\/p>\n<p>Run two robocopy jobs at the same time with <a href=\"http:\/\/ss64.com\/nt\/start.html\">START<\/a> \/Min<\/p>\n<pre>Start \/Min \"Job one\" Robocopy \\\\FileServA\\C$\\Database1 \\\\FileServeBackupA\\c$\\Backups\r\nStart \/Min \"Job two\" Robocopy \\\\FileServB\\C$\\Database2 \\\\FileServeBackupB\\c$\\Backups\r\n<\/pre>\n<p>Copy only permission changes (additions and removals) assuming we already have a copy of the data:<br \/>\n<span class=\"code\">ROBOCOPY \\\\FileServer\\C$ \\\\SVR-Backups\\c$\\Backups \/E \/Copy:S \/IS \/IT<\/span><\/p>\n<h2>Availability<\/h2>\n<p>Robocopy is a standard command in Windows 7 and above. The <a href=\"http:\/\/ss64.com\/links\/windows.html#kits\"> Windows Server 2003 Resource Kit Tools<\/a> include Robocopy XP010, which can be run on NT 4\/ Windows 2000. Robocopy does not run on Windows 95, or NT 3.5. (RoboCopy is a Unicode application).<\/p>\n<p>Robocopy &#8216;Jobs&#8217; and the &#8216;MOnitor source&#8217; option provide an alternative to setting up a <a href=\"http:\/\/ss64.com\/nt\/at.html\">Scheduled Task<\/a> to run a batchfile with a RoboCopy command.<\/p>\n<h1>Bugs<\/h1>\n<p>The Windows 7 \/Server 2008 R2 version of RoboCopy will incorrectly skip some files if the filenames contain East Asian characters, for example Japanese characters. A hotfix is available to correct this <a href=\"http:\/\/support.microsoft.com\/kb\/2680906\">KB2680906<\/a><\/p>\n<p>Version XP026 returns a success errorlevel even when it fails.<\/p>\n<p class=\"quote\"><i> \u201cOne, a robot may not injure a human being, or through inaction, allow a human being to come to harm\u201d &#8211; Isaac Asimov, Laws of Robotics from I. Robot, 195<\/i><\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>http:\/\/ss64.com\/nt\/robocopy.html ROBOCOPY.exe (XP Resource Kit\/Standard Windows 7 command) Robust File and Folder Copy. By default Robocopy will only copy a file if the source and destination have different time stamps or different file sizes. Syntax ROBOCOPY Source_folder Destination_folder [files_to_copy] [options] &hellip; <a href=\"https:\/\/stevenwhiting.com\/blog\/?p=1360\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[273],"class_list":["post-1360","post","type-post","status-publish","format-standard","hentry","category-it-notes","tag-robocopy"],"_links":{"self":[{"href":"https:\/\/stevenwhiting.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1360","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/stevenwhiting.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/stevenwhiting.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/stevenwhiting.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/stevenwhiting.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1360"}],"version-history":[{"count":3,"href":"https:\/\/stevenwhiting.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1360\/revisions"}],"predecessor-version":[{"id":1363,"href":"https:\/\/stevenwhiting.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1360\/revisions\/1363"}],"wp:attachment":[{"href":"https:\/\/stevenwhiting.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1360"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/stevenwhiting.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1360"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/stevenwhiting.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1360"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}