I have an rsync command that I run hourly via cron, and to prevent it from having multiple simultaneous rsyncs (should the previous hour's rsync still be running when the next hour comes around) I've wrapped it in an flock. My issue is that despite specifying an exclude filter that should prevent temporary files from being copied, I get 'file has vanished' messages output that seem to indicate they would have been copied (if they were still present).

Here's my script (being run by cron):

#! /bin/sh
cd /blah/data
flock -n .rsync_lock -c "rsync $1 -xa --exclude '/tmp*' --ignore-existing jcr/datastore remote-host:data/jcr"

And here's the output I get:

file has vanished: "/blah/data/jcr/datastore/tmp1774058021534447273.tmp"
file has vanished: "/blah/data/jcr/datastore/tmp2911761408812578785.tmp"
file has vanished: "/blah/data/jcr/datastore/tmp3744586075822519088.tmp"
file has vanished: "/blah/data/jcr/datastore/tmp6622502546708007750.tmp"
file has vanished: "/blah/data/jcr/datastore/tmp8270853704354349176.tmp"
rsync warning: some files vanished before they could be transferred (code 24) at main.c(977) [sender=2.6.9]

Why isn't my exclude filter stopping these files from being considered for transfer? Is this a weird bash quoting issue?

  • Shouldn't it be --exclude '*/tmp*' ? – R. S. Feb 7 '13 at 5:51

If you want to exclude those files your exclude pattern needs to be */tmp*.tmp.

  • Even though the files are in the base source directory specified for the rsync? Base: jcr/datastore File: jcr/datastore/tmp8270853704354349176.tmp – Trevor Horsfall Feb 8 '13 at 1:13

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.