Linux – Why is scp not overwriting the destination file

linuxoverwritescptimestamp

I'm trying to back up a file via the command

scp /tmp/backup.tar.gz hostname:/home/user/backup.tar.gz

When I run it, the scp progress bar shows up and it looks like its transferring the file, however when I log into the destination server to check the file, the timestamp and filesize haven't changed from the older version, so it looks like scp didn't overwrite the old file at
all. It only sees to work when I manually delete the file from the destination server.

I'm running ubuntu, and this is happening on two servers: one cygwin ssh, and one fedora core 3.

Anyone have any idea why this is happening? I thought scp would ONLY overwrite existing files..

Thanks

Best Answer

If I omit the destination file name and only specify directory, then it works:

scp /tmp/backup.tar.gz hostname:/home/user/

I don't understand why, but it might be solution to your problem as well.