Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm using rsync to sync files across multiple machines, using the following:

rsync -az -e "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" \
  --delete --delete-excluded --force --exclude=.git  --exclude=.bundle \
  --exclude=tmp --exclude=log/* --exclude=*.log --exclude=*.pid \
  user@host:/path/to/src/ /var/build/dest

I want to exclude all log files from being transferred from the source to destination, and delete all existing ones on the destination. So I'm using --exclude=*.log with --delete-excluded which works great.

But I want to keep a certain log file intact on the destination. I want an --exclude-from-delete option.

Is this possible with rsync?

share|improve this question

1 Answer 1

The "protect" filter should accomplish just what you want:

          protect, P specifies a pattern for protecting files from deletion.

Just specify the following filter before the relevant excludes:

--filter='P my-specific-logfile.log'

(Notice the space after the letter P.)

share|improve this answer
    
This actually works. –  fossilet Jul 10 '12 at 8:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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