Link to home
Start Free TrialLog in
Avatar of J G
J G

asked on

Copy NTFS permissions

Could someone suggest the best way to copy NTFS permissions from one folder to another folder on a new file server.

I am looking for ways to do it

1) while I am copying data
or
2) Data is already copied.  Need to apply permissions to new share.
ASKER CERTIFIED SOLUTION
Avatar of Fibertron
Fibertron
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ferrarista
ferrarista

I second that. Use robocopy.
Avatar of Shaun Vermaak
2) Data is already copied.  Need to apply permissions to new share.
https://helgeklein.com/setacl/examples/managing-file-system-permissions-with-setacl-exe/
Backup
SetACL.exe -on "\\server1\share1\users" -ot file -actn list
           -lst "f:sddl;w:d,s,o,g"
           -rec cont
           -bckp "d:\data\setacl listing.txt"

Open in new window


Restore
SetACL.exe -on "dummy entry" -ot file -actn restore
           -bckp "d:\data\setacl listing.txt"

Open in new window

2) Built-in icacls does it as well:
icacls \\server1\share\someproject /save AclFile /T
icacls \\server2\share /restore AclFile

Open in new window

The 2nd command will assume there's a copy of the folder someproject below \\server2\share.
Yes, but breaks on long paths
Oh, it does? Can you give me an example path, please? Sot SetACL.exe has no limitation?
The first hit on your google link holds a solution for that problem: "\\?\drive\folder", icacls "\\?\c:\somelongfolder
Didn't know that, or long forgotten maybe ;-)

So the author may choose if he'd like to mess with setacls syntax or use icacls maybe with the prefix \\?\ whatever seems easier.
Shaun, do me a favor and try this with icacls and setacls. For me, icacls works, while setacls does not work.

[using win10 1809 x64, here]
Objective: restore the ACLs of a new text file beneath a folder structure on c: to the same file on the same structure on d:

Step1: create the structure on c:
md c:\wödeljkhnflwkönlkjsdlk\wödeljkhnflwkönlkjsdlk\wödeljkhnflwkönlkjsdlk\wödeljkhnflwkönlkjsdlk\
subst e: c:\wödeljkhnflwkönlkjsdlk\wödeljkhnflwkönlkjsdlk\wödeljkhnflwkönlkjsdlk\wödeljkhnflwkönlkjsdlk
md e:\wödeljkhnflwkönlkjsdlk\wödeljkhnflwkönlkjsdlk\wödeljkhnflwkönlkjsdlk\wödeljkhnflwkönlkjsdlk
subst f: e:\wödeljkhnflwkönlkjsdlk\wödeljkhnflwkönlkjsdlk\wödeljkhnflwkönlkjsdlk\wödeljkhnflwkönlkjsdlk
md f:\wödeljkhnflwkönlkjsdlk\wödeljkhnflwkönlkjsdlk\wödeljkhnflwkönlkjsdlk\wödeljkhnflwkönlkjsdlk\
subst e: /d & subst f: /d

Open in new window

then create a text file within and set a special permission on it.
Step 2: create the same structure on d:
md d:\wödeljkhnflwkönlkjsdlk\wödeljkhnflwkönlkjsdlk\wödeljkhnflwkönlkjsdlk\wödeljkhnflwkönlkjsdlk\
subst e: d:\wödeljkhnflwkönlkjsdlk\wödeljkhnflwkönlkjsdlk\wödeljkhnflwkönlkjsdlk\wödeljkhnflwkönlkjsdlk
md e:\wödeljkhnflwkönlkjsdlk\wödeljkhnflwkönlkjsdlk\wödeljkhnflwkönlkjsdlk\wödeljkhnflwkönlkjsdlk
subst f: e:\wödeljkhnflwkönlkjsdlk\wödeljkhnflwkönlkjsdlk\wödeljkhnflwkönlkjsdlk\wödeljkhnflwkönlkjsdlk
md f:\wödeljkhnflwkönlkjsdlk\wödeljkhnflwkönlkjsdlk\wödeljkhnflwkönlkjsdlk\wödeljkhnflwkönlkjsdlk\
subst e: /d & subst f: /d

Open in new window

now copy the text file over using explorer.

Then try to apply the permissions from the structure on c: to the one on d:
Setacl failed here (using the method of example 2 and 3 of https://helgeklein.com/setacl/examples/managing-file-system-permissions-with-setacl-exe/ )

Does it work for you?
It is probably just a flag in the -lst to include files. Will have a look
Tike, it is time to hear your feedback on these suggestions, I think.
@Shaun: did you have a look at it by now?
@Tike: does this long-path-problem apply to you? if so, did you succeed with the suggestions? Would be helpful to know if setacl worked for you on long paths.