Friday, October 21, 2011

rsync files from cd...

I just started rsync to copy files from CD ROM. This was a usual form I use:
rsync -av source destination
But this time I ended up with some error messages and not a single file or a directory was copied. The error messages were like the following ones:
rsync: recv_generator: mkdir "/home/user/CD_final/ns-3-dev/bindings" failed: Permission denied (13)
*** Skipping any contents from this failed directory ***
ns-3-dev/build/
rsync: recv_generator: mkdir "/home/user/CD_final/ns-3-dev/build" failed: Permission denied (13)
*** Skipping any contents from this failed directory ***
After some wondering what happened, as this was the first time I got behavior like that, I very quickly realized that the problem is with write permissions, or more precisely directory write permissions. Namely, files and directories don't have write bit set on CDROM since there is no point in having it on read-only medium. But rsync was also clearing this bit on hard disk _before_ copying files into this directory. And what happened is that it couldn't write files and thus skipped the directory.

Some quick googling didn't give any results so I turned to man page. Quick search for a word permission and there was solution. :) I needed to add option --chmod which is used to change permissions of files and directories. POnly, I wanted only directory permissions to be changed, not of every file. But, there was example in the manual page that showed me that I have to call rsync like this:
rsync -av --chmod=Du+w source destination
After that, all the files were copied and the problem was quickly solved! :)

No comments:

About Me

scientist, consultant, security specialist, networking guy, system administrator, philosopher ;)

Blog Archive