I am backing up data from a GNU/Linux system to a CIFS mount. There are clear limitations to this, such as characters in filenames (eg. colons (:)) and symlinks not being supported by the destination Windows file system.

Rsync backup proceeds well enough using the following (note mirror backup):

rsync --bwlimit=62500 --log-file=${logfile} -av --no-links --delete ${src_dir} ${dest_dir}

Rsync reports errors on transferring file according to limitations above and returns error code:

rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1052) [sender=3.0.9]

Issue is that I want ensure rsync completes successfully, given the limitations of the destination file system.

The error code reported appears to be too general (code 23: Partial transfer due to error) to just skip over in the wrapper bash script that checks the return code ie, if I skip over this error I may ignore a failed backup.

I have tried adding exclusion criteria to rsync, such as --no-links --exclude='*:*', which does work on that specific case. However, this seems like a piece-meal solution as I would need to update this when new conditions arise that cause backup to fail due to destination file system incompatibilities.

I prefer not to tar backups as users require option to retrieve deleted files from backup.

Thanks for the help.

1 Answer 1


After some digging here is solution that works:

rsync --bwlimit=62500 --log-file=${logfile} -av -s --iconv=ISO-8859-1,utf-8 --no-links --delete ${src_dir} ${dest_dir}

Note the use of the -s and --iconv=ISO-8859-1,utf-8 option which allows for spaces in filenames (-s) and converts filename characters from Linux filename encoding (ISO-8859-1) to Windows (utf-8), --iconv=ISO-8859-1,utf-8. Also note the use of --no-links as symlinks are not supported by destination filesystem.

Limit on bandwidth (--bwlimit=62500) is specific to my implementation as the transfer takes place over a 1Gbit link that shares user SSH traffic as well.

The Windows share is mounted using mount.cifs like so:

mount.cifs ${win_share} ${local_mount_point} -o gid=16000,credentials=/root/.smbcredentials,file_mode=0775,dir_mode=0775,iocharset=utf8,cache=none,mapchars

Note the use of mapchars which enables the following (from man mount.cifs):


Translate six of the seven reserved characters (not backslash, but including the colon, question mark, pipe, asterik, greater than and less than characters) to the remap range (above 0xF000), which also allows the CIFS client to recognize files created with such characters by Windows´s POSIX emulation. This can also be useful when mounting to most versions of Samba (which also forbids creating and opening files whose names contain any of these seven characters). This has no effect if the server does not support Unicode on the wire. Please note that the files created with mapchars mount option may not be accessible if the share is mounted without that option.

I have tested the requirement of rsync flags --no-links and --iconv=ISO-8859-1,utf-8, as well as the mapchars option for mount.cifs. All are required for rsync to return successful error code of 0.

I will update this solution as I encounter filenames that break it.

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.