This site uses cookies to deliver our services and to show you relevant ads and job listings.
By using our site, you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service.
Your use of Stack Overflow’s Products and Services, including the Stack Overflow Network, is subject to these policies and terms.

Join us in building a kind, collaborative learning community via our updated
Code of Conduct.

Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

I am currently configuring Dirvish on a Linux computer for backing up the contents of a share on a Windows computer.

Dirvish creates a new directory every time it is called. It internally uses rsync for copying data, creates hard links for files that have not changed and copies those that have.

Normally, from Linux to Linux, it uses rsync over ssh where rsync is running on both sides of the connection so for those files that already exist, only a checksum is transferred which is pretty much instant even for large files.

When used on a Samba share, there is no rsync on the other computer so does rsync still provide any advantage over plain copy where network traffic is concerned?

1 Answer
1

Why use rsync instead of cp?
First, I wanted to quote Tim Morgan, who wrote three arguments on his blog post a few years ago, favoring rsync over cp:

It can be canceled in the middle, and resumed later.

It can show a progress bar that (while not perfect) is great for large files or lots of files.

It will only copy the changed files and won’t clobber already existing directories of files at the target.

rsync uses by default less traffic than cp, even on samba shares
In terms of network traffic, cp always copies the file contents, while rsync doesn't. The default behavior of rsync (see man page) is that it checks the file size and modification date/time. If those two attributes are the same, rsync assumes that the file is unaltered. This also works on Samba shares. This behavior can be changed using the -c or --checksum flag, which forces rsync to always do the check based on the checksum.

rsync -c uses (a little bit) more trafficIf you use the -c flag with rsync, there is the overhead of sending the filelist, which rsync does, but cp doesn't, so I think (not tested) rsync had a (very!) little bit more overhead than cp if rsync is used with the -c flag.