2

I'm currently using rsync as follows

rsync -az --delete ...

What option can I use with rsync to replace all destination files that already exist except for one specific file that should not be replaced if already exists? Sure, if the file doesn't exist at the destination, it should be put there.

2 Answers 2

3

I don't think you can do this with rsync filters. So I would exclude that file and run rsync a second time.

err=0
rsync -az --delete --exclude=/path/to/first-time.only source/ destination/ || err=1
rsync -az --ignore-existing --include=/path/to/first-time.only --exclude='*' source/ destination/ || err=1
return $err
1
  • 1
    I agree with Gilles, I don't think you can do this with a single rsync invoke. Commented Dec 2, 2013 at 23:47
0

cp -P /location/specificfile /user/yourname/elsewhere
rsync with your options
cp -force /user/yourname/elsewhere /location/specificfile

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.