-->
Adventures & experiences in contemporary technology
The rsync command is one that I use heavily for doing backups and web publishing. The latter means that it is part of how I update websites built using Hugo because new and/or updated files need uploading. The command also sees usage when uploading files onto other websites as well. During one of these operations, and I am unsure now as to which type is relevant, I encountered errors about being unable to set permissions.
The cause was the encompassing -a
option. This is a shorthand for -rltpgoD
, and the individual options perform the following:
-r
: recursive transfer, copying all contents within a directory hierarchy
-l
: symbolic links copied as symbolic links
-t
: preserve times
-p
: preserve permissions
-g
: preserve groups
-o
: preserve owners
-D
: preserve device and special files
The solution is to some of the options if they are inappropriate. The minimum is to omit the option for permissions preservation, but others may not apply between different servers either, especially when operating systems differ. Removing the options for preserving permissions, groups and owners results in something like this:
rsync -rltD [rest of command]
While it can be good to have a more powerful command with the setting of a single option, it can mean trying to do too much. Another way to avoid permissions and similar errors is to have consistency between source and destination files systems, but that is not always possible.