How to backup file permissions

Owen Townend owen.townend at gmail.com
Thu Apr 24 13:36:11 BST 2008


On 24/04/2008, ml at bortal.de <ml at bortal.de> wrote:
>
> Hello List,
>
> is there an way to backup file permissions (not the actual files!!).
> I need it for some bash script.
>
> Thanks, Mario


Hey,

  Something simple like this to save
# find . -printf '%p %m \n' > permissions.out
  Then something like this to restore
# awk '{system("chmod "$2" "$1)}' permissions.out

  Simple, easy to read, plaintext backup.
  It wouldn't be hard to add ownership to this if you want/need that too.

# find . -printf '%p %m %u %g \n' > permissions.out
# awk '{system("chmod "$2" "$1), system("chown "$3":"$4"
"$1)}' permissions.out

  This doesn't support filenames with spaces as it stands, but hopefully
works as a proof of concept...

cheers,
Owen.

--
> ubuntu-users mailing list
> ubuntu-users at lists.ubuntu.com
> Modify settings or unsubscribe at:
> https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://lists.ubuntu.com/archives/ubuntu-users/attachments/20080424/7fe9e84f/attachment-0001.htm 


More information about the ubuntu-users mailing list