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.
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.
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. :-)
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.
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.For me, rsync is the intuitive. If I want to backup my work, I sync those directories:
Try that with any other command:
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.
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. :-)
Yeah, I hit this peculiarity of rsync a couple of weeks ago and I had to write down the exact rsync command I wanted.