SCP Batch Backup
scp is a simple way to copy backup artifacts to another server. It is fine for one-off transfers or small setups, but it does not handle incremental synchronization as efficiently as rsync.
Quick Summary
- Use
scpto copy finished backup files (archives, dumps, logs). - Verify transfers with checksums.
- Prefer
rsyncfor repeatable backups.
Copy a batch of artifacts
scp-copy-backups.sh
scp /backups/wp-files-*.tar.* /backups/wp-db-*.sql.* backup@backup-host:/srv/wp-backups/site-a/
If you use a dedicated key:
scp-with-ssh-key.sh
scp -i ~/.ssh/wp-backup /backups/*.zst backup@backup-host:/srv/wp-backups/site-a/
Copy a directory recursively
scp-recursive-copy.sh
scp -r -i ~/.ssh/wp-backup /backups/snapshots backup@backup-host:/srv/wp-backups/site-a/
Verification (recommended)
Generate checksums locally, copy the checksum file, then verify on the remote.
scp-verify-with-sha256.sh
cd /backups
sha256sum wp-files-* wp-db-* > /tmp/backups.sha256
scp -i ~/.ssh/wp-backup /tmp/backups.sha256 backup@backup-host:/tmp/backups.sha256
ssh -i ~/.ssh/wp-backup backup@backup-host 'cd /srv/wp-backups/site-a && sha256sum -c /tmp/backups.sha256'
Common pitfalls
- Copying backups into a web-accessible directory.
- Using
scp -C(SSH compression) on already-compressed files (often no benefit). - Forgetting verification.
When to switch to rsync
Use rsync if:
- You run backups daily/weekly.
- You need resumable incremental transfers.
- You want to avoid re-copying unchanged files.
See:
opt/docker-data/apps/docusaurus/site/docs/server/linux-server/10-backup-disaster-recovery/ssh-backup-with-rsync.mdx