Workaround for rsyncing when fileflag schg is set?

Fred Fugate unclefreddie70 at
Sun Oct 31 00:04:08 UTC 2021


I have some subdirectories within a home directory that are chflagged schg,
aka system immutable.

When I rsync the home directory to another machine, I get lots of errors
for these subdirectories and they fail to copy to the target. NOTE: The
target is empty; rsync is copying to an empty remote machine, not trying to
overwrite anything.

I understand why this is happening; it's the schg flag. But is there a
workaround using some combination of rsync options or multiple passes?

Here is an example.

The source directory is /Users/redacted.

Within /Users/redacted is a subdirectory foo that has flag schg set:

# ls -laO /Users/redacted/Documents/artwork
total 80
drwxr-xr-x   20 redacted  staff  -        680 Sep 21 21:06 .
drwx------@ 609 redacted  staff  -      20706 Oct 29 16:07 ..
-rw-r--r--@   1 redacted  staff  -      18436 Sep 21 20:55 somefile
drwxrwxrwx@  18 redacted  staff  schg     612 Apr 12  2006 foo

My rsync args are:

--verbose --archive --one-file-system --acls --hard-links --xattrs
--protect-args --delete-after --numeric-ids --itemize-changes --crtimes
--fileflags --force-change

My rsync version is 3.2.3

My execution and output looks like this, run as root:

# /opt/rsync323/bin/rsync [ARGS ABOVE] /Users/redacted
rsync: [receiver] mkstemp
"/Users/redacted/Documents/artwork/foo/bar/.background.tiff.vYOAS2" failed:
Operation not permitted (1)
rsync: [receiver] mkstemp
failed: Operation not permitted (1)
rsync: [receiver] mkstemp
"/Users/redacted/Documents/artwork/foo/bar/.barcode.tiff.2E4mec" failed:
Operation not permitted (1)

In a nutshell:

Subdirectory foo gets created on the receiver, but it gets created with the
schg flag set.

No further copying into foo can happen after that, because the schg flag
prevents that.

Subdirectory bar cannot be created under foo, and .background.tiff.vYOAS2
and other files cannot be created under bar, etc.

How can I force the schg flags to be set on the receiver AFTER everything
has been copied from the source?

I really don't want to remove all of my schg settings on the source before
rsyncing to the target.

Would --no-perms allow this? But what would it break?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the rsync mailing list