19

Over the weekend I copied our company data from one hard drive to another larger one. I thought permission would have copied across but they haven't.

What is the best (and quickest) way to copy the permission that were originally set onto my new data, without having to copy all the data again? My users are now accessing the data so don't want to recopy the data as changes may be lost.

The data is hosted on windows server 2008 R2

Simon Foster
  • 2,712

6 Answers6

20

I think this will do the work:

robocopy source destination /E /COPY:SOU /xo /xn /xc /xx /LOG+:F:\Sec.log.

"SOU" copies: S=Security info (NTFS ACLs), O=Ownership info, U=aUditing info

If this does not work you can use this command to back up NTFS permissions:

icacls d:\data /save ntfspermissions.txt /t /c

The /T switch allows it to get subfolder permissions too. The /C switch allows it to continue even if errors are encountered (although errors will still be displayed).

And then use this command to restore the permissions:

icacls d:\ /restore ntfsperms.txt

Note that in the command to save the permissions, I specified the target folder D:\Data, but when I restored them, I specified just D:\ as the target. You might think specifying D:\ as the target in the restore command may somehow mess up the permissions on other folders at that level, but as you can see from the ntfspermissions.txt output file, it only has information about the Data folder and subfolders, so that is all it will change.

7

Using PowerShell:

Get-Acl 'source path' | Set-Acl 'destination path'
torvin
  • 274
0

You can try using Robocopy. AFAIK it still works on newer Windows versions.

pritaeas
  • 119
0

Like Priaeas said, robocopy.

Handy reference guide for switches to use.

/copyall or /copy:DATSOU will copy "everything" (data, attributes, timestamps, NTFS ACLs, owner and auditing info).

/COPY:copyflag[s] : What to COPY (default is /COPY:DAT) (copyflags : D=Data, A=Attributes, T=Timestamps S=Security=NTFS ACLs, O=Owner info, U=aUditing info).

HopelessN00b
  • 54,273
0
xcopy e:\*.* z: /T /E /I /H /K /X /Y

e: was the root of a physical drive with several shares and all kinds of inheritance blocks dotted about. z: was the "new" drive, in this case a mapped drive.

It just worked, not for the shares, just the permissions.

-4

CopyMik Freeware Program mit Keys:

/CSF[ FileMask1[ FileMask2[ ....]]]] Copy file security attributes. Only files with the specified mask. (default mask *)

/CSD[ DirMask1[ DirMask2[ ....]]]] Copy folder security attributes. Only folders with the specified mask. (default mask *)

http://www.superbasis.de/copymik/index.htm