In the remote directory I have a file 'checkpoint.tar', I also ended up transferring a file with the same name 'checkpoint.tar' from my home directory to the remote directory via scp
.
I then cancelled this transfer halfway through.
Will the file be corrupted by this half-overwrite? Will it have reverted to the original state?
Asked
Active
Viewed 316 times
0

Somni
- 3
1 Answers
2
scp
does not do anything special with its target file(s). It uses a standard "truncate and write" approach, so the target file checkpoint.tar
will now consist of a partial copy of your most recent source file.
You can verify this by looking at the file date and size, and also running tar tvf checkpoint.tar
from the destination server to list the files the tarball contains.

Chris Davies
- 116,213
- 16
- 160
- 287
cp
, and cancel it half way through? I bet the same thing happens. – RonJohn Mar 31 '23 at 20:15cp
and your libc, the filesystem on which you're copying (or whether you cross filesystems) and how larger your file is. – Marcus Müller Mar 31 '23 at 22:52copy_file_range
by default, with copy sizes above what you usually get per read/write pair, so that larger files get copied atomically fromcp
's perspective. (Given filesystem support of course) – Marcus Müller Mar 31 '23 at 22:57