Unable to rsync files from RHEL 7 to RHEL 6 with SELinux enabled

Latest response

If i try to rsync files from a RHEL 7 to a RHEL 6 with SELinux enabled on both machines and with -XA flags on rsync I get this error:
rsync: rsync_xal_set: lsetxattr("etc/.pwd.lock","security.selinux") failed: Invalid argument (22)

The problem seems to be related to the fact that RHEL 7 has selinux contexts that don't exist on RHEL 6.

Is there any way to get around this other than turning of SELinux on the RHEL 6?


You may be able to use the rscyn --ingnore-non-existing option.

But I want those files also to be copied over. Preferably with the correct context.

Is there any way to tell SELinux to accept unknown contexts or turn of checking contexts only on a certain folder?

This problem is possible also between machines of same OS major versions if there are SELinux file contexts defined in the source machine that are not defined in the target machine. Rsync reports then that lsetxattr failed with invalid argument and sets the file context to unlabeled_t on the target machine. The file itself is transferred however but needs to be manually contexted unless autolabeling takes care of it later.