When modifying permissions on Windows I backup the ACLs to a file first using a commands like:
subinacl /noverbose /output=C:\temp\foldername_redir_permissions_backup_star_star.txt /subdirectories "W:\foldername\*.*"
and…
subinacl /noverbose /output=C:\temp\foldername_redir_permissions_backup.txt /subdirectories "W:\foldername\"
…to back them up.
And then if they need to be restored, a command like…
subinacl /playfile C:\temp\foldername_redir_permissions_backup_star_star.txt
…can be used to restore them.
So can the same thing be done for POSIX permissions on Linux / Unix? And what about ACL extended permissions?
Best Answer
setfacl
is designed to acceptgetfacl
output as input. Meaning you can rungetfacl
, save the output to a file, do your thing, then restore the ACL. The exact procedure can vary depending on your platform. On Linux though:You can also use
--set-file
on thesetfacl
you use to restore and set it to-
if you want to pipe the old ACL in. You can also usegetfacl -R
to backup the ACL's of entire directory trees.