I have a source directory which I'm periodically syncing to a target using rsync:
rsync --bwlimit=1600 --recursive --times
--omit-dir-times --copy-links --modify-window=30
--inplace --delete-before --progress --stats --whole-file
--itemize-changes --human-readable ./ /media/0123-4567/
The target media is just the right size for the sync: the target is a 1000 MB partition, source has 990 MB of files; syncing from source to an empty target works fine.
The problem is when I'm syncing to a target which contains an older version: some of the existing source files are smaller in the current version, and some new are added. The total size stays 990 MB; but rsync seems to choose a strategy "copy new files first, then update the existing," the first part won't work, because the space that's supposed to be freed with the update is not there yet.
version 1 version 2
files not changed: 800 MB 800 MB
new files in v2: 0 MB 80 MB
files changed between versions: 190 MB 110 MB
total 990 MB 990 MB
In other words, how can I make rsync update the target first (which will, in my case, free up space), and only then add new files?
So far, I have hacked around this by having two separate invocations, only differing in this parameter:
rsync --existing [...]
rsync --ignore-existing [...]
This will update the existing files first, and copy the new ones later; Is there a way to do this with one command?
--delete-before
; I haven't found any *--update-before
or somesuch in the manpage.