Ubuntu – rsync mkstemp failed Invalid argument (22) with davfs mount of Box.com cloud

clouddavfs2dropboxrsyncUbuntu

I mounted Box.com cloud storage using davfs according to these instructions. I mounted my Box.com account under /home/me/Cloud/Box

I can access the mounted filesystem via Dolphin as well as via the terminal. It is a little slow, but I can list (ls) and navigate the entire directory structure with no errors.

Next I attempted to run rsync as follows:

rsync -auvz  --max-size=250M --exclude '.*' /home/me/Music/ /home/me/Cloud/Box/Music

I also tried:

rsync -auv  /home/me/Music/A /home/me/Cloud/Box/Music

and other variations of rsync commands. The command is copying my Music from my local file system (/home/me/Music/) to the Box cloud (/home/me/Cloud/Box/Music) via the davfs mount.

I always get a lot of errors of this form:

rsync: mkstemp <filename> failed: Invalid argument (22)

A specific example is:

rsync: mkstemp "/home/me/Cloud/Box/Music/VariousArtists/.01_Track_1.mp3.YVmFI9" failed: Invalid argument (22)

This is all happening on Kubuntu 12.04 LTS 64 bit, server grade hardware, with a fast/reliable cable modem connection (12 Mb/s upload speeds).

Best Answer

The problem occurs because of rsync making temporary files with filenames that the box.com and/or davfs do not understand. Thus the file .01_Track_1.mp3.YVmFI9 does not exist on your system, but is a temporary artefact of rsync. Some guesswork from my side: if you don't get the error on all files, you probably only get the errors on files that were already uploaded (and changed).

It used to be impossible to switch off this temporary file generation, but you might nowadays have more luck by adding the option --inplace. However the advantages of using rsync if you are not talking to a rsync-daemon (which you are not if you are using davfs), are unclear to me.

Therefore, as an alternative, you could try cp --update, which only copies a file when the source is newer than the destination. New files and any files with changes in ID3 tags will get copied, others will not.

Or if you need to have more control use find:

cd /home/me/Music/
find * -size -250M -print0 | cpio -pdmv0 /home/me/Cloud/Box/Music

this preserves the hierarchy structure and cpio does not overwrite existing files that are not older.

Related Question