Cygwin: recursive copy with ACLs


/ Published in: Bash
Save to your folder(s)

Cygwin's `cp` discards ACLs (complex windoze permissions). You have to copy them separately as follows:


Copy this code and paste it in your HTML
  1. # First copy files themselves, with timestamps:
  2. cp -a folder1 folder2
  3.  
  4. # Set all ACLs of copies to ACLs of originals:
  5. cd folder2
  6. find . | while read f ; do getfacl ../folder1/"$f" | setfacl -f - "$f" ; done
  7.  
  8. # or when permissions are equal for all files / directories:
  9. getfacl folder1 > folder-perms
  10. getfacl folder1/file > file-perms
  11. find folder2 -type d -exec setfacl -f folder-perms '{}' \;
  12. find folder2 -type f -exec setfacl -f file-perms '{}' \;
  13. # or probably faster:
  14. find folder2 -type d -print0 | xargs -0 setfacl -f folder-perms
  15. find folder2 -type f -print0 | xargs -0 setfacl -f file-perms

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.