Backup file permissions


Backup

A simple example shows how to do this using a single command line statement. I want to backup the permissions on the folder E:\ZedaTest and it’s subfolders and -files.
To do so, I created a batchfile containing the following command.

icacls.exe E:\Data\Zedatest\* /save E:\Data\acl_zedatest.txt /t /c

20110221-backupfilepermissions
This script reads all file permissions of the files and folders including subfolders (/t), ignoring errors (/c). Results are written to the file E:\Data\acl_zedatest.txt. This file looks like this:

Folder1 D:AI(A;OICIID;FA;;;WD)(A;OICIID;FA;;;SY)(A;OICIID;FA;;;BA) Folder2 D:AI(A;OICI;FA;;;S-1-5-21-2427325736-2493757636-818923003-2778)(A;OICIID;FA;;;WD)(A;OICIID;FA;;;SY)(A;OICIID;FA;;;BA) Folder3 D:AI(A;OICIID;FA;;;WD)(A;OICIID;FA;;;SY)(A;OICIID;FA;;;BA) Folder1\testfile1.txt D:AI(A;ID;FA;;;WD)(A;ID;FA;;;SY)(A;ID;FA;;;BA) Folder2\testfile3.txt D:AI(A;ID;FA;;;S-1-5-21-2427325736-2493757636-818923003-2778)(A;ID;FA;;;WD)(A;ID;FA;;;SY)(A;ID;FA;;;BA) Folder3\testfile1.txt D:AI(A;ID;FA;;;WD)(A;ID;FA;;;SY)(A;ID;FA;;;BA) Folder3\testfile2.txt D:AI(A;ID;FA;;;WD)(A;ID;FA;;;SY)(A;ID;FA;;;BA) Folder3\testfile3.txt D:AI(A;ID;FA;;;WD)(A;ID;FA;;;SY)(A;ID;FA;;;BA)

Icacls.exe can handle logical drives, network drives and UNC paths.
NOTE:   The path I specify ends with \*. Without this addition, the backup works well but the restore must be performed on the parent folder. Because this is confusing I recommend to use the addition \* at all times.

Restore

If needed you can restore the file permissions using the following command

—————————————–This post applies to: Windows 2008, Windows 2008 R2, Windows 7.———————————-

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: