Windows IT Pro is the leading independent community for IT professionals deploying Microsoft Windows server and client applications and technologies.
  
  
  Advanced Search 



JSI Tip 9945. How can a script backup or restore NTFS permissions?

RSS
Subscribe to Windows IT Pro | See More Backup and Recovery Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

Using the corrected version of SubInAcl, I have scripted NTFSBKP.bat to backup or restore NTFS permissions.

The syntax for using NTFSBKP.bat is:

NTFSBKP DriveOrFolder DestinationFolder BKP|RST

Where:

DriveOrFolder      is the drive, or folder, including files and sub-folders, 
                   whose NTFS security you wish to backup or restore. 

DestinationFolder  is the destination folder that will contain /does contain
                   two files that hold backed up security attributes.

BKP|RST            BKP causes NTFSBKP.bat to backup the NTFS security.
                   RST causes NTFSBKP.bat to restore the NTFS security from the previous backup.
NTFSBKP.bat contains:
@echo off
If {%3}=={} @echo Syntax: NTFSBKP DriveOrFolder DestinationFolder BKP^|RST&goto :EOF
if not exist %1 @echo NTFSBKP - %1 NOT FOUND.&goto :EOF
if not exist %2 @echo NTFSBKP - %2 NOT FOUND.&goto :EOF
if /i {%1}=={%2} @echo Syntax: NTFSBKP DriveOrFolder DestinationFolder BKP^|RST&goto :EOF
if /i {%3}=={BKP} goto OK
if /i {%3}=={RST} goto OK
@echo Syntax: NTFSBKP DriveOrFolder DestinationFolder BKP^|RST&goto :EOF
:OK
setlocal
set DorF=%1#
set DorF=%DorF:"=%
set DorF=%DorF:\#=%
set DorF=%DorF:#=%
set Fld=%2#
set Fld=%Fld:"=%
set Fld=%Fld:\#=%
set Fld=%Fld:#=%
set Sw=%3
set F1=%DorF%
set F1=%F1::\=_%
set F1=%F1:\=_%
set F2="%Fld%\%F1%_ALL.log"
set F1="%Fld%\%F1%.log"
if /i "%Sw%" EQU "RST" goto Restore
set D1="%DorF%"
set D2="%DorF%\*.*"
if exist %F1% del /q %F1%
if exist %F2% del /q %F2%
subinacl /noverbose /nostatistic /outputlog=%F1% /subdirectories %D1% /display
subinacl /noverbose /nostatistic /outputlog=%F2% /subdirectories %D2% /display
endlocal
goto :EOF
:Restore
if not exist %F1% goto :Rest1
if not exist %F2% goto :Rest2
subinacl /nostatistic /playfile %F1%
subinacl /nostatistic /playfile %F2%
endlocal
goto :EOF
:Rest1
@echo NTFSBKP %1 %2 %3 - %F1% NOT FOUND.
endlocal
goto :EOF
:Rest2
@echo NTFSBKP %1 %2 %3 - %F2% NOT FOUND.
endlocal



End of Article



Reader Comments

You must be a registered user or online subscriber to comment on this article. Please log on before posting a comment. Are you a new visitor? Register now




Top Viewed ArticlesView all articles
Battery Life Issues Almost Certainly Not Windows 7's Fault

While Microsoft is still investigating a notebook battery life issue that was supposedly caused by Windows 7, some interesting trends have emerged. ...

Confirmed: Battery Life Issues Not Windows 7's Fault

Microsoft on Monday issued a lengthy statement about the recent Windows 7 battery controversy, echoing my assessment from earlier in the day, but backing it up with hard, cold evidence. Put simply, Windows 7 is not responsible for any battery life issues ...

Getting your iPhone to Sync with Exchange 2003

Follow these steps to use an iPhone with Exchange. ...


Related Events Why We Do Backups and Do We Even Know How to Use Them?

New Year Savings Plan: How to get more out of your backup with new technologies like data deduplication, server virtualization and others

Real World Applications of Storage Strategy

Check out our list of Free Email Newsletters!

Related Resources Introducing Left-Brain.com, the online IT bookstore
Looking for books, CDs, toolkits, eBooks? Prime your mind at Left-Brain.com

Discover Windows IT Pro eLearning Series!
Clear & detailed technical information and helpful how-to's, all in our trademark no-nonsense format


Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro DevProConnections IT Job Hound
Left-Brain.com Technology Resource Directory asp.netPRO ITTV Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 © 2010 Penton Media, Inc. Terms of Use | Privacy Statement