How to Use the icacls Command to Backup and Restore NTFS File Permissions in Windows

The File Permission Nightmare

In a Windows enterprise environment, NTFS file permissions are the bedrock of data security. They dictate exactly which users and groups can read, write, or execute files within a shared network drive.

However, these permissions are fragile. A junior administrator attempting to fix an access issue might accidentally check the box for “Replace all child object permission entries with inheritable permission entries from this object.” Instantly, thousands of customized folder permissions across a massive departmental share are wiped out and replaced with generic top-level access.

Rebuilding these permissions manually via the GUI (right-clicking every folder > Properties > Security) would take weeks. To prevent this catastrophe, you should proactively backup your NTFS permissions using the built-in Windows command-line tool: icacls.

Step 1: Understanding icacls

icacls (Integrity Control Access Control List) is the modern replacement for the older cacls command. It allows you to view, modify, backup, and restore ACLs for files and directories directly from the Command Prompt.

You must run these commands from an elevated command prompt.

  1. Click Start, type cmd.
  2. Right-click Command Prompt and select Run as administrator.

Step 2: Backing Up Permissions

Let’s assume you have a critical network share located at D:\FinanceData. You want to save every single permission setting for every file and subfolder inside it.

The syntax for a backup is:

icacls "D:\FinanceData" /save "C:\Backup\FinanceACL.txt" /t /c

Breaking down the flags:

  • “D:\FinanceData”: The target directory.
  • /save “C:\Backup\FinanceACL.txt”: Instructs the tool to dump the data into a text file at this location. (Do not save the backup inside the folder you are backing up).
  • /t: Traverses all subfolders and files recursively.
  • /c: Continues processing even if an “Access Denied” error occurs on a specific file, rather than aborting the entire script.

When you run this, icacls will silently scan the directory. The resulting FinanceACL.txt file will be completely unreadable to a human (it uses unicode and specific internal security identifiers), but it is a perfect blueprint for Windows.

Step 3: Restoring Permissions

Assume the worst has happened, and the permissions on the FinanceData folder were corrupted. You need to apply your backup.

The restore syntax is slightly counterintuitive. You do not point the command at the specific folder; you point it at the parent directory containing the folder, and feed it the text file.

Because the folder is located at D:\FinanceData, the parent directory is simply D:\.

icacls "D:\" /restore "C:\Backup\FinanceACL.txt" /c

Windows will read the text file, find the references to the FinanceData folder inside it, and rapidly re-apply every single security group, user restriction, and inheritance flag exactly as they were the moment you ran the backup.

Step 4: Automating the Backup

Because icacls is a command-line utility, it is easily automated.

You can create a simple batch file (e.g., BackupPermissions.bat) containing the backup command, and then use the Windows Task Scheduler to run that script every Sunday at 2:00 AM.

If you do this, it is highly recommended to append a dynamic timestamp to the filename so you don’t overwrite your previous backups. In a batch file, that looks like this:

set stamp=%date:~-4,4%%date:~-10,2%%date:~-7,2%
icacls "D:\FinanceData" /save "C:\Backup\FinanceACL_%stamp%.txt" /t /c

By keeping a running archive of your NTFS permissions, you transform a potential multi-day administrative disaster into a simple five-minute recovery operation.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.