7

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

public_html/images/made/96096a4645d59a3e/Moulin_à_vent_Bourgogne_DBW1901_1200_801_80.jpg

Is it possible to stop rsync from converting the characters?

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

1 Answer 1

6

Need to use --iconv.

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

--iconv=CONVERT_SPEC 
 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.
3
  • 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
    Commented Jun 18, 2018 at 11:10
  • 1
    --iconv=utf-8-mac,utf-8, or vice-versa ?
    – steve
    Commented Jun 18, 2018 at 16:34
  • you need rsync 3.something to have the iconv option. The default rsync version on mac is 2.6.x Commented Jun 3, 2023 at 21:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .