Files – How to Back Up and Restore File Permissions

aclbackupfilespermissions

Is there a way to back up and restore file ownership and permissions (the things that can be changed with chown and chmod)?

You can do this in Windows using icacls.

What about access control lists?

Best Answer

You can do this with the commands from the acl package (which should be available on all mainstream distributions, but might not be part of the base installation). They back up and restore ACL when ACL are present, but they also work for basic permissions even on systems that don't support ACL.

To back up permissions in the current directory and its subdirectories recursively:

getfacl -R . >permissions.facl

To restore permissions:

setfacl --restore=permissions.facl
Related Question