Rsync: Copying files across machines

Rsync is usually faster than scp. Here are what the options mean:

  • -a: option treats the entire path as an archive (recursively downloads everything and preserves file attributes)
  • -z: compress file before copying it over just for the file transfer. This minimizes the amount of data that needs to be transferred over and speeds up file copy.
  • -P: show progress indicator; also, resume from any previous partial downloads

As far as I can tell, here are the benefits of scp over this approach:

  • It does not require any special software running on the remote machine. Rsync requires that the remote machine has rsync too. In my experience, I’ve never seen this be an issue. Most linux systems will have rsync installed.
  • scp is secure by default. You need to ask rsync to use ssh for it to be secure.

If we were being very semantic and you wanted to just copy a file over, scp is the right tool and does not try to do any of the smart optimizations to speed up the copy process that rsync does - like checking mod-time and size of local file before deciding if it should be copied over from the remote machine. rsync is a tool for synchronizing directories across machines. However, for most situations - it works quite well as a replacement for scp.

Update: Turns out you could use scp -C option to enable compression on scp to bring it more in line with the -z option of rsync. Rsync still has the other benefits such as preserving file attributes, optimizing what to transfer based on local presence of the file etc.

References:

--

--

--

Adventuring through life. Stories of software development, engineering, fun, and reflection.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Your Guide to Understand NetSuite Pricing in 2021

Advent of Code 2020: Day 10

Deploy WordPress and MySQL on K8s with the help of Custom Build Docker Images

What are Software Design Patterns & An Introduction to Factory Design Pattern

software design patterns, Factory design pattern

Industrial Use Case of Azure Kubernetes Service : WhiteSource

TryHackMe: Watcher

Web Scrapping with Selenium and Beautiful Soup. (Part-1b)

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Aishwar Muthuraman

Aishwar Muthuraman

Adventuring through life. Stories of software development, engineering, fun, and reflection.

More from Medium

Install docker on CentOS 8 | Rocky Linux 8

Install docker on CentOS 8 | Rocky Linux 8

Python monorepo with Pants

Setting up Apptainer to Make Container Environments

Configure Multiple Github Accounts On Local