I am using rsync to backup my website files, using --link-dest to copy from the previous rsync backup.

rsync -zavx -e 'ssh -p22' \
   --numeric-ids \
   --delete -r \
   --link-dest=../"$latest_backup" "$rhost:$rhost_source" "$local_dest";

I have noticed that files with non-ascii characters look to have had their characters converted, so the rsync is deleting them and then re-downloading them.

Here is an example:

deleting public_html/images/made/96096a4645d59a3e/Moulin_a?\#200_vent_Bourgogne_DBW1901_680_680_s_c1.jpg


Is it possible to stop rsync from converting the characters?

  • 1
    What kind of filesystems are used on the source and target here?
    – Kusalananda
    Jun 17 '18 at 18:29
  • Sorry @Kusalananda, what do you mean by filesystem?
    – ccdavies
    Jun 17 '18 at 18:34
  • Is one filesystem NTFS and another ext4 or exFAT, or something similar?
    – Kusalananda
    Jun 17 '18 at 18:56
  • The source is a linux server and the destination a Mac computer. Does that help?
    – ccdavies
    Jun 17 '18 at 19:03
  • @roaima both are just paths
    – ccdavies
    Jun 17 '18 at 19:16

Need to use --iconv.

From the man page https://linux.die.net/man/1/rsync

 Rsync can convert filenames between character sets using this option. 
 Using a CONVERT_SPEC of lq.rq tells rsync to
 look up the default character-set via the locale setting. Alternately,
 you can fully specify what conversion to do by giving a local and a
 remote charset separated by a comma in the order --iconv=LOCAL,REMOTE,
 e.g. --iconv=utf8,iso88591. This order ensures that the option will
 stay the same whether you're pushing or pulling files. Finally, you
 can specify either --no-iconv or a CONVERT_SPEC of lq-rq to turn off
 any conversion. The default setting of this option is site-specific,
 and can also be affected via the RSYNC_ICONV environment variable.
  • Thank you Steve. I have tried adding '--iconv=us-ascii,utf8' to my rsync, but I am getting 'unknown option' returned. As far as I can tell, files stored on my server are 'utf8' and 'us-ascii' on my Mac.
    – ccdavies
    Jun 18 '18 at 11:10
  • 1
    --iconv=utf-8-mac,utf-8, or vice-versa ?
    – steve
    Jun 18 '18 at 16:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.