{"id":1647,"date":"2015-12-25T13:13:38","date_gmt":"2015-12-25T18:13:38","guid":{"rendered":"http:\/\/wildow.com\/?p=1647"},"modified":"2015-12-25T13:13:38","modified_gmt":"2015-12-25T18:13:38","slug":"robocopy-mir-switch-mirroring-file-permissions","status":"publish","type":"post","link":"https:\/\/wildow.com\/?p=1647","title":{"rendered":"Robocopy \/MIR switch \u2013 mirroring file permissions"},"content":{"rendered":"<h3 class=\"post-name\">Robocopy \/MIR switch \u2013 mirroring file permissions<\/h3>\n<div class=\"post-rating\"><span class=\"ui-rate rating readonly\" title=\"Average rating: 3 out of 2 ratings.\" data-contentid=\"f6c587e4-b6d9-4a31-8ba3-970461870240\" data-contenttypeid=\"f7d226ab-d59f-475c-9d22-4a79e3f0ec07\" data-readonly=\"true\" data-initialvalue=\"0.6\" data-initialcount=\"2\" data-configuration=\"ReadOnly=true\"><img decoding=\"async\" src=\"http:\/\/blogs.technet.com\/utility\/images\/star-left-on.png\" alt=\"\" align=\"absmiddle\" border=\"0\" \/><img decoding=\"async\" src=\"http:\/\/blogs.technet.com\/utility\/images\/star-right-on.png\" alt=\"\" align=\"absmiddle\" border=\"0\" \/><img decoding=\"async\" src=\"http:\/\/blogs.technet.com\/utility\/images\/star-left-on.png\" alt=\"\" align=\"absmiddle\" border=\"0\" \/><img decoding=\"async\" src=\"http:\/\/blogs.technet.com\/utility\/images\/star-right-on.png\" alt=\"\" align=\"absmiddle\" border=\"0\" \/><img decoding=\"async\" src=\"http:\/\/blogs.technet.com\/utility\/images\/star-left-on.png\" alt=\"\" align=\"absmiddle\" border=\"0\" \/><img decoding=\"async\" src=\"http:\/\/blogs.technet.com\/utility\/images\/star-right-on.png\" alt=\"\" align=\"absmiddle\" border=\"0\" \/><img decoding=\"async\" src=\"http:\/\/blogs.technet.com\/utility\/images\/star-left-off.png\" alt=\"\" align=\"absmiddle\" border=\"0\" \/><img decoding=\"async\" src=\"http:\/\/blogs.technet.com\/utility\/images\/star-right-off.png\" alt=\"\" align=\"absmiddle\" border=\"0\" \/><img decoding=\"async\" src=\"http:\/\/blogs.technet.com\/utility\/images\/star-left-off.png\" alt=\"\" align=\"absmiddle\" border=\"0\" \/><img decoding=\"async\" src=\"http:\/\/blogs.technet.com\/utility\/images\/star-right-off.png\" alt=\"\" align=\"absmiddle\" border=\"0\" \/><\/span><\/div>\n<div class=\"post-author\"><span class=\"profile-usercard-hover\" data-profile-userid=\"00000000000000000000000000000000\"> <span class=\"user-name\"> <a href=\"http:\/\/social.technet.microsoft.com\/profile\/cfsbloggers\">cfsbloggers<\/a> <\/span> <\/span><\/div>\n<div class=\"post-date\"><span class=\"value\"> 31 Jul 2008 3:08 PM <\/span><\/div>\n<div class=\"post-attributes\">\n<ul class=\"attribute-list\">\n<li class=\"attribute-item post-reply-count\"><span class=\"attribute-value\"><a class=\"internal-link view-replies\" href=\"http:\/\/blogs.technet.com\/b\/filecab\/archive\/2008\/07\/31\/robocopy-mir-switch-mirroring-file-permissions.aspx#comments\">4<\/a><\/span><\/li>\n<\/ul>\n<\/div>\n<div class=\"post-content user-defined-markup\">\n<p>Some customers pointed out what they believe to be a bug in Robocopy.<\/p>\n<p>The situation is: suppose that you copy your files using Robocopy in Windows Server 2003 or XP. Then, file or folder permissions (ACLs) are changed wither on source or destination. You want to use the \/MIR switch to mirror the permissions:<\/p>\n<p><b>&gt; ROBOCOPY source destination \/MIR\u00a0 \/SEC<\/b><\/p>\n<p>Robocopy fails to mirror file permissions \u2013 but works for folder permissions.<\/p>\n<p>This behaviour is by design. Robocopy focuses on copying just files that have changed (in size or modified date, by default). If a file looks like it has changed, Robocopy copies its data and, if you specified copying security as well, copies NTFS ACL from source to target after copying the data. If a file looks like it has NOT changed, Robocopy by default skips it, and copies nothing for the file, not even its security info.<\/p>\n<p>When I wrote the \u201csecurity copy\u201d part of Robocopy on 22 May 1997, I chose to do this for performance reasons, to keep Robocopy times for large trees down. This was an adequate implementation for most peoples\u2019 needs at the time. Also, another reason I chose to do things the way I did, is that setting security on directories is sufficient for most people. Setting security on a file-by-file basis is a more granular approach, for sure, but incurs a larger maintenance overhead, perhaps too much for many users.<\/p>\n<p>Therefore, the solution listed as a workaround posted by <a href=\"http:\/\/msmvps.com\/blogs\/martinzugec\/archive\/2008\/03\/03\/ugly-bug-in-robocopy-ignoring-security-on-file-level.aspx\">Martin Zugec (MVP)<\/a> is precisely what needs to be done in this situation, and this behaviour is expected:<\/p>\n<p><b>&gt; ROBOCOPY \/Mir &lt;Source&gt; &lt;Target&gt;<br \/>\n&gt; ROBOCOPY \/E \/Copy:S \/IS \/IT &lt;Source&gt; &lt;Target&gt;<\/b><\/p>\n<p>The first Robocopy command above will copy data and security for files that have been updated, and the second Robocopy command will refresh file security for all files, without copying any file data.<\/p>\n<p>If using a Resource Kit version of Robocopy, and wanting to keep security synced between two trees where the data is fairly static, but security is updated now and then. In fact, the \u201cCopying NTFS Security Information\u201d section of Robocopy.doc (from the Resource Kits) states:<\/p>\n<p>\u201cTo refresh security information for existing destination files and directories without copying file data, use the <b>\/IS<\/b> switch together with the <b>\/COPY<\/b> switch without the <b>D<\/b> flag. For example <b>\/IS<\/b> <b>\/COPY:SOU <\/b>would refresh all security information for all selected files, without copying any file data.\u201d<\/p>\n<p>Things have moved on a bit in the past 11 years, security-wise, so I changed the way things work in this area slightly for the version of Robocopy that ended up in Vista, in that if you specify \/SECFIX on the command line, Robocopy <i>will<\/i> copy security for skipped files that exist in both the source and the target trees.<\/p>\n<p>So, to maintain two trees in sync, including their security, using Vista\u2019s Robocopy, you can use the following as your regular Robocopy command:<\/p>\n<p><b>&gt; <\/b><b>ROBOCOPY <\/b><b>&lt;source&gt; &lt;target&gt; \/MIR \/SEC \/SECFIX<\/b><\/p>\n<p>\/MIR will replicate data and security (as \/SEC is specified) for changed files, and \/SECFIX will update just the security for unchanged files. Add \/V to the command line if you want to see which files are having their security \u201cfixed\u201d without having their data copied.<\/p>\n<p><i>Kevin Allen<\/i><\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Robocopy \/MIR switch \u2013 mirroring file permissions cfsbloggers 31 Jul 2008 3:08 PM 4 Some customers pointed out what they believe to be a bug in Robocopy. The situation is: suppose that you copy your files using Robocopy in Windows &#8230; <a class=\"more-link\" href=\"https:\/\/wildow.com\/?p=1647\">Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13,4],"tags":[],"class_list":["post-1647","post","type-post","status-publish","format-standard","hentry","category-scripting","category-windows"],"_links":{"self":[{"href":"https:\/\/wildow.com\/index.php?rest_route=\/wp\/v2\/posts\/1647","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wildow.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wildow.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wildow.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wildow.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1647"}],"version-history":[{"count":1,"href":"https:\/\/wildow.com\/index.php?rest_route=\/wp\/v2\/posts\/1647\/revisions"}],"predecessor-version":[{"id":1648,"href":"https:\/\/wildow.com\/index.php?rest_route=\/wp\/v2\/posts\/1647\/revisions\/1648"}],"wp:attachment":[{"href":"https:\/\/wildow.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1647"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wildow.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1647"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wildow.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1647"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}