0

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

Jakuje
  • 21,357
Zama Ques
  • 3,276

1 Answers1

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

Gokul
  • 1,071