It does create a temp file, by default in the target directory and named .<FILE_NAME>.<RANDOM_STRING>
. So, if you are copying foo.txt
, it will create a tmp file called .foo.txt.GV4H3
(GV4H3
is the random string that will be different every time you run it). You can control this behavior using these rsync
options:
--partial
By default, rsync will delete any partially transferred
file if the transfer is interrupted. In some circum‐
stances it is more desirable to keep partially trans‐
ferred files. Using the --partial option tells rsync to
keep the partial file which should make a subsequent
transfer of the rest of the file much faster.
--partial-dir=DIR
A better way to keep partial files than the --partial
option is to specify a DIR that will be used to hold
the partial data (instead of writing it out to the des‐
tination file). On the next transfer, rsync will use a
file found in this dir as data to speed up the resump‐
tion of the transfer and then delete it after it has
served its purpose.
Please read the relevant parts of the rsync
man page (the following is only a small extract of the large section on how to use --partial-dir
).
4Important note! The question assumes rsync "copies the file into place", whereas the rsync documentation specifies that rsync is actually "moving it into place", which is an IMORTANT DISTINCTION. This ensures that the file appears in the destination location in an atomic fashion. This is useful for preventing race conditions where another application is waiting for the destination file to appear and immediately opens it for reading, but the file is not done being copied. – Ogre Psalm33 – 2017-01-12T16:08:04.223