In the past, I think we all have went to change ownership/permissions of a bunch of directories/files only to realize we made a mistake and accidently change the wrong files. So I have started backing up permissions using a tool called “getfacl”. You just do a “getfacl -R /home/httpd/corp > /tmp/backup.acl” and that writes all of the files, their ownership and permissions and any flags (ie: sticky bit, etc) to the file backup.acl. THEN, if you want to restore it, it’s a simple command.
On Debian, just do an “apt-get install acl” and it will give you both the getfacl (to get/backup the permissions) and setfacl (to restore the permissions). Here is an example of the commands: http://linuxconfig.org/backup-permissions-in-linux