Wednesday, March 19, 2008

Restore ACL or copy file with ACLs

First copy the ACLs:

getfacl --omit-header /your/file/or/directory /here > file.txt

this command store the current ACLs in file.txt.

Then run:

setfacl -M file.txt /your/file/or/directory/here

this command sets the ACLs same as the stroed file.

To copy the file or directory while preserving ACLs, use the -p or -a command option (-R means recursive and that means with all subdirectories):

copy -R -p /your/source/dir your/teraget/dir


copy -R -a /your/source/dir your/teraget/dir

To copy files with ACLs from one computer to another use RSYNC:

rsync -avrzA /source/dir

-A parameter means:
preserve ACLs (implies -p).
-a: Archive
-r: Recursive
-v: Verbose
-z: compress during copy

No comments: