1. 26
  1. 13

    The rsync thing has screwed me up in the past. I generally have to write a sync script and then just never manually use rsync as a workaround to not being able to remember how it works.

    1. 5

      I should probably do this more often, I just habitually use the -n option to do a dry-run and make sure it’s doing what I actually expect.

      1. 4

        For me, rsync is the intuitive. If I want to backup my work, I sync those directories:

        rsync -a work/ /backup-work/
        

        Try that with any other command:

        cp -a work/ /backup-work/
        

        Oops, this only does the right thing the first time. The second time, when backup-work exists, it means something else!

        Ref idempotent commands, I think this is even an objective argument for rsync’s trailing slash semantics. Except that it wouldn’t/shouldn’t have to be about the trailing slash.

        1. 3

          Yeah, with rsync you basically always want a trailing slash on both source and destination. The exception is when you’re syncing a single file… in which case of course you don’t want a trailing slash. :-)

          1. 2

            Yeah, I hit this peculiarity of rsync a couple of weeks ago and I had to write down the exact rsync command I wanted.