How to write idempotent Bash scripts
It happens a lot, you write a bash script and half way it exits due an error. You fix the error in your system and run the script again. But half of the steps in your scripts fail immediately because they were already applied to your system. To build resilient systems you need to write software that is idempotent.
Source: How to write idempotent Bash scripts, an article by Fatih Arslan.