Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
rsync to fat32: Filenames with illigal characters
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
pa4wdh
l33t
l33t


Joined: 16 Dec 2005
Posts: 913

PostPosted: Fri Feb 14, 2025 5:55 am    Post subject: rsync to fat32: Filenames with illigal characters Reply with quote

Hi All,

I'm trying to rsync some files from a linux filesystem to a USB flash drive which has to be fat32 formatted. For most files this works, but some filenames contain characters that are not allowed in fat32. Is there a way for rsync to translate those characters to others that are allowed on fat32?
I've found the iconv parameter for rsync, which seems to be able to do what i need, but i don't understand how i should use it.

Has anyone done anything similar to this?

Thanks in advance.
_________________
The gentoo way of bringing peace to the world:
USE="-war" emerge --newuse @world

My shared code repository: https://code.pa4wdh.nl.eu.org
Music, Free as in Freedom: https://www.jamendo.com
Back to top
View user's profile Send private message
Banana
Moderator
Moderator


Joined: 21 May 2004
Posts: 1893
Location: Germany

PostPosted: Fri Feb 14, 2025 6:47 am    Post subject: Reply with quote

From rsync man
Quote:
--iconv=CONVERT_SPEC
Rsync can convert filenames between character sets using this
option. Using a CONVERT_SPEC of "." 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 push-
ing or pulling files.


So --iconv=utf8,iso88591 could help.

But it could be also a file system spec problem.
Read more here: https://medium.com/@pratikpanchal/rsync-between-ntfs-and-fat32-formatted-storage-devices-731ae4b011e2

Quote:
Since FAT32 uses a 2-second resolution, this should overcome this problem:
rsync --archive --no-p --no-g --no-o --modify-window=2 source destination

_________________
Forum Guidelines

PFL - Portage file list - find which package a file or command belongs to.
My delta-labs.org snippets do expire
Back to top
View user's profile Send private message
sMueggli
Guru
Guru


Joined: 03 Sep 2022
Posts: 544

PostPosted: Fri Feb 14, 2025 5:04 pm    Post subject: Reply with quote

I do not think that rsync can change filenames on the fly.

The clean solution is to rename all files with illegal characters on both filesystems.

The other solution is to archive the source and rsync only the archive. But that is only a good solution if you do not need to access the files on the FAT-formatted partition.

I guess the illegal characters are all part of the ASCII table and are therefore not affected by any codepage conversion.
Back to top
View user's profile Send private message
pa4wdh
l33t
l33t


Joined: 16 Dec 2005
Posts: 913

PostPosted: Fri Feb 14, 2025 5:51 pm    Post subject: Reply with quote

Thanks for your answers.

Indeed, illegal characters include ?, which is plain ascii and would not be converted. In this case i do not want to modify the source as this is just a temporary solution. Unfortunately archiving is not an options for my use case.

Last resort would be to write a script to do this, but i hoped to prevent that :)
_________________
The gentoo way of bringing peace to the world:
USE="-war" emerge --newuse @world

My shared code repository: https://code.pa4wdh.nl.eu.org
Music, Free as in Freedom: https://www.jamendo.com
Back to top
View user's profile Send private message
grknight
Retired Dev
Retired Dev


Joined: 20 Feb 2015
Posts: 2017

PostPosted: Fri Feb 14, 2025 6:14 pm    Post subject: Reply with quote

Use tar and output to a valid file name on the USB device.
Back to top
View user's profile Send private message
pa4wdh
l33t
l33t


Joined: 16 Dec 2005
Posts: 913

PostPosted: Fri Feb 14, 2025 7:01 pm    Post subject: Reply with quote

What do you mean grknight? I've searched the manual but didn't find anything about changing filenames.

In the mean time i've written a basic script to copy the files with some translation, it works for now which is good enough :)
_________________
The gentoo way of bringing peace to the world:
USE="-war" emerge --newuse @world

My shared code repository: https://code.pa4wdh.nl.eu.org
Music, Free as in Freedom: https://www.jamendo.com
Back to top
View user's profile Send private message
grknight
Retired Dev
Retired Dev


Joined: 20 Feb 2015
Posts: 2017

PostPosted: Fri Feb 14, 2025 7:46 pm    Post subject: Reply with quote

pa4wdh wrote:
What do you mean grknight? I've searched the manual but didn't find anything about changing filenames.

In the mean time i've written a basic script to copy the files with some translation, it works for now which is good enough :)

A tar archive can include files which wouldn't natively support on a file system. Just name the new file something that can be transported and unarchive after.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum