Minimal working example
- Let's suppose we have two directories
a
andb
- File
1.txt
exists ina
and it containsfoo
- We copy
a/1.txt
tob
usingrsync
- File
a/1.txt
gets modified and now it containsbar
- In order to have the updated version of
a/1.txt
inb
, we executersync
again
At this point a/1.txt
contains bar
, while b/1.txt
contains foo
.
The scenario described above can be reproduced by executing the following commands.
mkdir a b
echo foo > a/1.txt
rsync -a a/ b
echo 'After first run'
cat a/1.txt
cat b/1.txt
echo bar > a/1.txt
rsync -a a/1.txt b/
echo 'After second run'
cat a/1.txt
cat b/1.txt
After first run
foo
foo
After second run
bar
foo
As you could see above, the content of b/1.txt
was not updated with the content of a/1.txt
in the second run.
The question
How to make rsync
update the content of files that have been copied in a previous run?
System information
$ rsync --version
rsync version 3.2.7 protocol version 31
Copyright (C) 1996-2022 by Andrew Tridgell, Wayne Davison, and others.
Web site: https://rsync.samba.org/
Capabilities:
64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints,
socketpairs, symlinks, symtimes, hardlinks, hardlink-specials,
hardlink-symlinks, IPv6, atimes, batchfiles, inplace, append, ACLs,
xattrs, optional secluded-args, iconv, prealloc, stop-at, no crtimes
Optimizations:
SIMD-roll, no asm-roll, openssl-crypto, no asm-MD5
Checksum list:
xxh128 xxh3 xxh64 (xxhash) md5 md4 sha1 none
Compress list:
zstd lz4 zlibx zlib none
Daemon auth list:
sha512 sha256 sha1 md5 md4
rsync comes with ABSOLUTELY NO WARRANTY. This is free software, and you
are welcome to redistribute it under certain conditions. See the GNU
General Public Licence for details.
rsync
works as expected and givesfoo
/foo
thenbar
/bar
. What filesystem are you using?