‹ BackHN Continuity

Thread

cp: -r or -R?

126 points · 110 comments · zdw

  1. pasc1878 · · focus · HN ↗
    Use rsync instead
    1. trucks-refinish · · focus · HN ↗
      rsync unfortunately doesn't do relinking at all, so I can't use it as a generic replacement for cp.
      1. groestl · · focus · HN ↗
        Relinking?
        1. rincebrain · · focus · HN ↗
          I assume they typoed reflinking, a way of doing CoW-based copying of file contents.
          1. groestl · · focus · HN ↗
            I was under the impression it could do that, I think I build a snapshotting mechanism using this.
            1. Flimm · · focus · HN ↗
              rsync does not have the ability to copy a file using the filesystem's copy-on-write feature. This is unlike cp, which has the --reflink flag. Here's the bug report on GitHub which the developers closed as "won't fix for now":

              <a href="https:&#x2F;&#x2F;github.com&#x2F;RsyncProject&#x2F;rsync&#x2F;issues&#x2F;119#issuecomment-3769076742" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;RsyncProject&#x2F;rsync&#x2F;issues&#x2F;119#issuecommen...

          2. trucks-refinish · · focus · HN ↗
            yes thank you!
    2. 5555watch · · focus · HN ↗
      In my minimal attempts to use rsync, I always find examples where they always use a ton of flags alongside the locations. I&#x27;m not gonna learn those flags if cp can do it intuitively and with minimal extra commands. Maybe it&#x27;s just me.
      1. CoastalCoder · · focus · HN ↗
        Not just you.

        Also, I always have this vague fear that I&#x27;ll rsync in the wrong direction, or accidentally blow away unrelated files in rsync&#x27;s efforts to fully synchronize two directories (can&#x27;t remember if this is a valid concern).

        I&#x27;m sure these concerns would go away if I used it regularly, but I just don&#x27;t. ‘cp&#x27; or ’scp’ almost always meet my needs.

        Kinda like the way people are probably right that I should learn to use ’awk’, but I just can&#x27;t muster the motivation.

        1. toast0 · · focus · HN ↗
          &gt; Also, I always have this vague fear that I&#x27;ll rsync in the wrong direction

          It&#x27;s the same direction as cp&#x2F;scp ... You could easily do it wrong, but you must be afraid to do anything other than maybe cat &lt; source &gt; dest because that&#x27;s clear?

          &gt; or accidentally blow away unrelated files in rsync&#x27;s efforts to fully synchronize two directories (can&#x27;t remember if this is a valid concern).

          I think you need --delete for this. As I recall, it&#x27;s sometimes more tricky to get it to delete the files you wanted it to delete and you&#x27;re more likely to end up with extra files than removing files you didn&#x27;t intend to.

      2. groestl · · focus · HN ↗
        Do it once, make it your muscle memory - it&#x27;s really hard for me to learn things by heart, but even I could do it :), and then you can forget about scp as well
Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.