Hacker News new | ask | show | jobs
by Panino 14 days ago
I've been using openrsync here and there since it was announced and it's definitely improved over time. I'm looking forward to when I can use it exclusively.

The one place in my usage where it doesn't match Samba rsync is with the following:

openrsync --rsync-path=openrsync -av -e ssh /etc/services example.com:/tmp/services

I would expect openrsync to create a remote file /tmp/services, but instead it creates /tmp/services/services.

Normal directory mirroring as in -av -e ssh /path/to/src/ example.com:/path/to/dst/ works as it does with Samba rsync.

4 comments

> The one place in my usage where it doesn't match Samba rsync is with the following:

> openrsync --rsync-path=openrsync -av -e ssh /etc/services example.com:/tmp/services

This appears to match "normal" `rsync` behavior as well. I think you need a trailing slash after `services` to sync only the contents.

EDIT: actually my "normal" rsync is openrsync on macOS...

This switch happened in macOS 15.4, it was pretty easy to miss.
sounds like a compliment to the implementation
Or more likely that prior to 15.4, macOS was using an ancient version of rsync because Apple wants to avoid the GPL 3.0. rsync went GPL 3.0 in 2007.
Nonetheless, this matches vanilla rsync.
No, it doesn't.

I think some people may not be reading closely. On Unix, "/etc/services" is a file, not a directory:

  $ file /etc/services                                                                                                                         
  /etc/services: ASCII text
Here are two OpenBSD 7.9 endpoints running Samba rsync:

rsync -av -e ssh /etc/services example.com:/tmp/services

The above command creates a mirror of the local file /etc/services in a remote file called /tmp/services. The outcome is exactly the same as if I had run "scp /etc/services example.com:/tmp/services"

  client$ sha256 -q /etc/services                                                                                                                    
  469d28e72ed0e0994d31b555cc1bed7bc95a23fd1beeb30062affb64db0dd44a

  server$ sha256 -q /tmp/services                                                                                                          
  469d28e72ed0e0994d31b555cc1bed7bc95a23fd1beeb30062affb64db0dd44a
openrsync --rsync-path=openrsync -av -e ssh /etc/services example.com:/tmp/services

The above command creates a mirror of the local file /etc/services in a remote file called /tmp/services/services. The outcome is NOT the same as if I had run "scp /etc/services example.com:/tmp/services"

Please note that "/tmp/services" and "/tmp/services/services" are different.

  client$ sha256 -q /etc/services                                                                
  469d28e72ed0e0994d31b555cc1bed7bc95a23fd1beeb30062affb64db0dd44a

  server$ sha256 -q /tmp/services  
  sha256: /tmp/services: read error: Is a directory
  server$ sha256 -q /tmp/services/services                                                                                                 
  469d28e72ed0e0994d31b555cc1bed7bc95a23fd1beeb30062affb64db0dd44a
Here's an OpenBSD 7.9 client and Ubuntu server both running Samba rsync:

rsync -av -e ssh /etc/services example.com:/tmp/services

The above command creates a mirror of the local file /etc/services in a remote file called /tmp/services. The outcome is exactly the same as if I had run "scp /etc/services example.com:/tmp/services"

If you disagree, please state what operating systems you're using and copy/paste the output of the following commands on each side:

  uname -a
  rsync -V
  openrsync -V
I get

  $ rsync -V
  rsync  version 3.4.3  protocol version 32
  (snipped)

  $ openrsync -V
  openrsync 0.1 (protocol version 27)
Then please run the commands I ran above, in particular

openrsync --rsync-path=openrsync -av -e ssh /etc/services example.com:/tmp/services

And then type "file /tmp/services" on the remote server.

Was there already a /tmp/services directory on the dest?

One of the biggest points of confusion with rsync is how directories and trailing slashes are handled.

I hear that a lot, but I familiarized myself with it once and ever since it makes a lot of sense to me.

Source ending in “/“: You want what’s inside. Source not ending in “/“: You want the thing (i.e. directory itself). For the destination, it does not matter whether it ends in “/“ or not, but for consistency I like adding a “/“ anyway (I want to put thing inside the directory).

Yes, the nice thing about dest having a trailing "/" is that if it exists and is NOT a directory, you are alerted right away.
It's a big source of confusion with cp. One of the UI reasons to use rsync (for mundane non-remote copying) is that it doesn't do different things based on what's present on the target.
> Was there already a /tmp/services directory on the dest?

No. And just to make sure, I ran a quick 'rm -rf /tmp/services' on the remote host, then re-ran openrsync on the client. Same result. This is OpenBSD 7.9 on both sides.

And I 100% agree about trailing slashes.

If you use a trailing slash on the source it copies from the directory, if you omit the trailing slash it copies the directory itself. AFAIK this is pretty standard across POSIX tools
It's not, for example cp -R doesn't change behavior on the basis of a trailing slash on directory names.
Indeed. This is one of the differences between the Unix and the MS/PC/DR-DOS command-line world. In the latter, recognizing empty final pathname components actually did become a way of differentiating such situations. I wrote a set of DOS and OS/2 tools in the 1990s, including COPY and MOVE commands, that had this very behaviour. I wasn't alone.
I was implementing something recently and stumbled across that cp difference. ugh.

the trailing slash is pretty convenient.

that's not a cp difference, cp is the granddaddy here

I think trailing / could be a nice way to indicate some meaningful difference, but since autocomplete always sticks it in, just feels like a bad idea to me. I might like it if directory names always had to have a trailing /, but I am less motivated by "convenience of common cases" and much more by "absolute precision/specificity/unambiguity" belt and suspenders.

(kind of unrelated but along the same lines, I toy with the idea of getting rid of . and .. visible in the filesystem, and make them only part of the syntax of paths. then you could have unambiguous multiple links to a directory: ".. is where you came from" and .. in the root is still the root, so chroot works too)

I think . and .. are useful. there's also perforce's ... which I find interesting (for example foo/... means everything below directory "foo")
> I would expect openrsync to create a remote file /tmp/services, but instead it creates /tmp/services/services.

As someone who has also suffered uncountable years of abuse from rsync, I understand the impulse, but I think it makes a lot more sense (and is a safer default) to create a second ”services”.

If we have a chance to change rsync defaults to something less insane and save future generations from this mess I think we should.

We don't, since we're not implementing a UI from scratch, we're matching something else.

Of the two possible worlds where in one this reimplementation matches what some see as annoyances in the interface or in another they mostly match the interface except for a few cases where the purposefully diverge (for no good technical reason), IMO the latter is far worse and causes more enexpected behavior.

At most, add a special flag to opt into different default behavior so nobody is surprised by running the same command on different systems and getting different behavior.

To be absolutely clear, since on reading this later it may come across as me masquerading as part of the OpenBSD project, I am not affiliated with them. My "We don't" was in response to "If we have a chance to change rsync defaults" which we, as the general public and users (and very likely also any reimplementors) don't have that chance, because rsync has a solid UI that people and tools have integrated for over a decade, and that's not something you can just change.
you responded to a comment that states "we should", your comment is a clear response to that. at least i understood it as intended.