When to automate a repetitive task:

NO-BRAINER: "This is obviously going to be faster to automate than to do it by hand _even once_. Let's automate it right now, and not do it by hand at all."

FORESIGHTED: "Doing it once by hand is faster than automating it, but I'm going to have to do it a lot of times, so it still saves time to automate it first."

NEED A RUN-UP: "I don't yet understand this task well enough to automate it, so I'll do it a few times by hand first to get the idea."

RAN OFF THE RUNWAY: "Great, now I've done this by hand a few times, I think I can automate it reliably! Oh, oops, turned out I only had one more case of it left to do."

TERRIFIED OF RUNNING OFF THE RUNWAY: "This is a one-off, so it would be a waste of time to automate it, I'll just do it manually."
[next day] "Oh, oops, I made a mistake and have to do it again. But it should be fine this time."
[a month later] "Even though I've had to redo it 25 times already, surely _this_ is the last time? So it would still be a waste of time to automate it."

@simontatham I'm a fan of the variant of "need a run-up", where you don't know what you're doing, but want to make sure that when you have to redo it, you redo the working steps the same way.

The best way of doing this is to write down the steps. In a script. So when you do get it working, you have most of your automation already written.

@darkling
I've had tasks that:
- I know I'll need to do exactly 5 times
- are complicated
- have many unknown unknowns - many thngs could go wrong, but I don't know which ones
- any of those unknown unknowns could do a lot of damage

I don't automate those, since I can't do error handling for an error I can't anticipate.

I write down what I'm doing, with commands, including a lot of sanity checks, and what to expect from an output.

Then I repeat these steps by hand.
@simontatham

@wolf480pl @simontatham If any damage isn't reversible, then absolutely.

I've mostly used my pattern in things like new data-ingest pipelines, where you can keep the original upstream data, and just nuke the interim stuff and try again if it all goes wrong.