necrux
- Blog
Backup and Restore Permissions in Linux
Inevitably every Linux administrator will eventually have to alter permissions and owerships, perhaps even FACLs. But what happens when your changes go awry? The problem is amplified if you were making changes recursively!
Backup Permissions
Fortunately there is a pretty simple method to backup the permissions, ownerships, and FACLs:
getfacl -pR /path/to/backup > /root/perms.bak
Note: Older versions of getfacl may not have the -p
flag; instead use ‐‐absolute-names
.
Restore Permissions
And if you need to restore the permissions:
setfacl --restore=/root/perms.bak
Note: The restore command does not expand ~, so if the backup location is in your home directory be sure to type the full path!