Rsync with colons in filenames

recursiversync

I have a fairly large directory that I need to sync to an external hard drive for both backup and portability reasons.

/work

I try to run the following rsync command in order to copy this folder to my external hard drive:

rsync -avz /work /media/extern_drive --max-size '4G'

Which seems to work fine, EXCEPT that it does not copy any file with a : in it.

This post gives a solution for a single file:
rsync: colon in file names, but the problem is that I have so many of these files scattered in different directories that I cannot do it manually.

Is there any way to recursively rsync any files with a colon in the filename?

Best Answer

I surmise that your external drive uses a filesystem such as VFAT which doesn't allow colons in file names.

A simple option would be to back up your files as archives (zip, 7z, tar.xz, whatever catches your fancy). This way you wouldn't be limited by any characteristic of the filesystem other than the maximum file size.

Another possibility would be to use rdiff-backup, which takes care of translating file names that don't fit on the destination filesystem, as suggested by poolie.

A generic approach to unsupported characters is to leverage the filesystem layer to transform the file names. The FUSE filesystem posixovl transforms file names into names that Windows's VFAT supports.

mkdir ~/mnt
mount.posixovl -S /media/extern_drive ~/mnt
rsync -a /work ~/mnt
fusermount -u ~/mnt

See How can I substitute colons when I rsync on a USB key? for more details, and check that thread for any new solution that may come up.

Related Question