4

I am having difficulties finding how Rsync "chooses" the extension for the temporary file created while copying the file if I don't use the --inplace option.

Example : I want to copy sourceDirectory/myFile.txt into targetDirectory/ with Rsync.

While copying myFile.txt into targetDirectory/ Rsync will create a file named .myFile.txt.W4zvLi in targetDirectory/.

Then Rsync will rename .myFile.txt.W4zvLi into myFile.txt.

The question is how why Rsync uses the W4zvLi extension and why it seems to change each time I execute the Rsync program?

countermode
  • 7,533
  • 5
  • 31
  • 58

2 Answers2

5

rsync uses the mktemp(3) POSIX function to generate a unique temporary file name. You pass a template string to the mktemp function, and it will return a file name with any X characters in the template replaced by a random character.

In particular, rsync passes .XXXXXX to mktemp. If you want to try it out from the command line you can use the mktemp(1) binary like so:

mktemp -u "/tmp/foo.XXXXXX"
remmy
  • 5,055
  • 1
  • 24
  • 30
0

man rsync:

Beginning with rsync 3.1.1, the  temp-file  names  inside
              the specified DIR will not be prefixed with an extra dot (though
              they will still have a random suffix added).
Ipor Sircer
  • 14,546
  • 1
  • 27
  • 39