ZEDA.nl

ZEDA.nl

Tips & Tweaks for Windows

User Rating:  / 1
PoorBest 

Backup file permissions

When it comes to backup, it's good to have multiple options. Besides the normal file backup, I have the habit to backup the file permissions of important folders aswel. This allows me to restore file these permissions without losing file changes.

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

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.

icacls.exe E:\Data\zedatest /restore E:\Data\acl_zedatest.txt

This post applies to: Windows 2008, Windows 2012, Windows 7, Windows 8.

ZEDA.nl

Tips & Tweaks for Windows

Most read:

Ad:

Tools:

EU e-Privacy Directive

This site uses cookies for analytics, advertising and functional purposes. Please accept or decline the use of coockies on this site.

You have declined cookies. This decision can be reversed.

You have allowed cookies to be placed on your computer. This decision can be reversed.