framp
framp

Reputation: 141

rsync --ignore-times doesn't behave the way I expect

I read this thread and according this rsync option --ignore-times or -I should sync files even the timestamp and the file size is identical.

I wrote a small testscript to test this but if I use option -I all files are synced even only one file was updated with a same size and has the same date and should be copied now.

That's my testscript

#!/bin/bash

OPT="-r -iI"
#OPT="-r -i"

rm -rf src
rm -rf tgt

mkdir src
mkdir tgt

touch constantDate

echo "Initial" > src/contentsupdatedwithdifferentsize
echo "Initial" > src/contentsupdatedbutsamesizeanddate
touch -d "$(date -R -r constantDate)" src/contentsupdatedbutsamesizeanddate
echo "Initial" > src/dateupdatedonly
echo "Initial" > src/notupdated
echo "--- Init ---"
rsync -r $OPT src/ tgt/
sleep 3s

echo "Initial" > src/dateupdatedonly
echo "Updated" > src/contentsupdatedbutsamesizeanddate
touch -d "$(date -R -r constantDate)" src/contentsupdatedbutsamesizeanddate
echo "UpdatedUpdated" > src/contentsupdatedwithdifferentsize
echo "--- Updated ---"
rsync $OPT src/ tgt/
sleep 3s

echo "Updated" > src/contentsupdatedbutsamesizeanddate
touch -d "$(date -R -r constantDate)" src/contentsupdatedbutsamesizeanddate
echo "--- Updated2 ---"
rsync $OPT src/ tgt/

As soon as I use option -I all files are synced in all rsync calls. When I remove option -I in the first update the two files which were updated are synced (the file with same date and file size is not synced - as expected) and in the last update no file is synced even one file was updated with the same size and same date - as expected.

Option -I will according man rsync sync a file if the size and date is identical. I have no idea what I'm doing wrong :-(

I created a testscript and expect only the file which has different contents but same timestamp and same size to be synced when I use option -I.

Output of the script without -I is

--- Init ---
>f+++++++++ contentsupdatedbutsamesizeanddate
>f+++++++++ contentsupdatedwithdifferentsize
>f+++++++++ dateupdatedonly
>f+++++++++ notupdated
--- Updated ---
>f.sT...... contentsupdatedwithdifferentsize
>f..T...... dateupdatedonly
--- Updated2 ---

which is what I expect.

The output with option -I is

--- Init ---
>f+++++++++ contentsupdatedbutsamesizeanddate
>f+++++++++ contentsupdatedwithdifferentsize
>f+++++++++ dateupdatedonly
>f+++++++++ notupdated
--- Updated ---
>f..T...... contentsupdatedbutsamesizeanddate
>f.sT...... contentsupdatedwithdifferentsize
>f..T...... dateupdatedonly
>f..T...... notupdated
--- Updated2 ---
>f..T...... contentsupdatedbutcontentsupdatedbutsamesizeanddatesamesizeanddate
>f..T...... contentsupdatedwithdifferentsize
>f..T...... dateupdatedonly
>f..T...... notupdated

which I don't expect. Updated2 should show only contentsupdatedbutsamesizeanddate.

Upvotes: 2

Views: 108

Answers (1)

Cyrus
Cyrus

Reputation: 88839

With option -I rsync disables checks for time and size. This causing all files to be updated.

See man rsync.

Upvotes: 1

Related Questions