0

This question already has an answer here:

We are using rsync to copy files from one location to another location on a different host. We want to exclude a directory from the source location so that files from this directory are not copied . The files inside this directory are actually session data and this data were removed once the session completes . So we are excluding this directory.

For this we modified our rsync to exclude the directory as follows:

rsync -av --exclude '/share/web/moodle/moodledata/sessions/' --rsync-path "sudo rsync" /share/ 172.31.X.X:/share/ &>/home/fsync/rsyncjob/output."$datetime";

But I can see that the directory is not getting excluded as from the log file can see it is trying to copy the log file:

rsync: send_files failed to open "/share/web/moodle/moodledata/sessions/sess_bnktcuvnv965dj4qtv1438o651": Permission denied (13)
rsync: send_files failed to open "/share/web/moodle/moodledata/sessions/sess_d2vvo9ip79jc13qafgq5of50s2": Permission denied (13)

Please suggest fix to exclude the directory

marked as duplicate by roaima, Jakuje, terdon Jan 21 '16 at 10:28

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1

Always try to see if there's already a similar discussion before posting the question.

With rsync, all exclude (or include) paths beginning with / are are anchored to the root of transfer. The root of transfer in this case is /share. Use relative path, instead of absolute path and it should work.

For further reference,

rsync exclude directory not working

Not the answer you're looking for? Browse other questions tagged or ask your own question.