Clone mounts as is

Hello,

Iam trying to clone AS IS two mounts like below

/class_test/sa
/class_dev/fd

from one server onto another.

I want to use tar and gzip to compress. Please let me know the options I have to use.

Also I want to untar it in the destination server, so let me know how to do that too.

Please keep in mind my main criteria is AS IS ( permissions, owner, group everything )

For those kinds of tasks I'm always using CPIO. Try that:

cd /class_test/sa; find . | cpio -o | gzip | ssh root@remote 'cd /class_test/sa && gunzip | cpio -imdu'

cpio won't preserve SELinux contexts, if you are using Linux and have SELinux enabled, or ACL's.

If you require those consider using star instead, something like:

cd /class_test/sa
star -xattr -acl -H=exustar -c -f=- . | ... | star -x -acl -f=.

Can anyone give an example of how to use tar to achieve this?