SCP – Is a checksum required

backupchecksumscp

I'm backing up and transferring files automatically each night via scp.

I realize I get packet-level checksums via the protocol itself, but I'm wondering what the best practice is to ensure that a transfer hasn't failed, or partially completed etc.

I could use rsync, but my needs are simple and I just want to ensure that:

  1. there wasn't an error in transmission
  2. retry if there was (so that I don't discover that I'm 4 days stale when I go to recover)

Best Answer

scp does not guarantee file integrity, so a checksum comparison between source and destination would be wise.

You mention your needs are simple, but rsync does not necessarily add complexity and offers significantly more features that will make you feel more comfortable that your synced data is legit.

rsync -ave ssh /your/source/file remotehost:/your/dest/file

If $? (exit status) is not 0 (success), then retry/alert/etc... If you are syncing entire directories, rsync is also much more suited for that, especially if you need to retry on failure, as incremental syncs will be significantly faster with each successive run.