# I am the Watcher. I am your guide through this vast new twtiverse.
# 
# Usage:
#     https://watcher.sour.is/api/plain/users              View list of users and latest twt date.
#     https://watcher.sour.is/api/plain/twt                View all twts.
#     https://watcher.sour.is/api/plain/mentions?uri=:uri  View all mentions for uri.
#     https://watcher.sour.is/api/plain/conv/:hash         View all twts for a conversation subject.
# 
# Options:
#     uri     Filter to show a specific users twts.
#     offset  Start index for quey.
#     limit   Count of items to return (going back in time).
# 
# twt range = 1 8
# self = https://watcher.sour.is/conv/zzyjqvq
This weekend (_as some of you may now_) I accidently nuke this Pod's entire data volume ๐Ÿคฆโ€โ™‚๏ธ What a disastrous incident ๐Ÿคฃ I decided instead of trying to restore from a 4-month old backup (_we'll get into why I hadn't been taking backups consistently later_), that we'd start a fresh! ๐Ÿ˜… Spring clean! ๐Ÿงผ -- Anyway... One of the things I realised was I was missing a very critical Safety Controls in my own ways of working... I've now rectified this...
So I re-write this shell alias that I used all the time alias dkv="docker rm" to be a much safer shell function:


dkv() {
  if [[ "$1" == "rm" && -n "$2" ]]; then
    read -r -p "Are you sure you want to delete volume '$2'? [Y/n] " confirm
    confirm=${confirm:-Y}
    if [[ "$confirm" =~ ^[Yy]$ ]]; then
      # Disable history
      set +o history

      # Delete the volume
      docker volume rm "$2"

      # Re-enable history
      set -o history
    else
      echo "Aborted."
    fi
  else
    docker volume "$@"
  fi
}
Then I cleaned up my shell history of all of the invocations I ever made of dkv rm ... to make sure I never ever have this so easily accessible in my shell history (^R):


$ awk '
  /^#/ { ts = $0; next }
  /^dkv rm/ { next }
  { if (ts) print ts; ts=""; print }
' ~/.bash_history > ~/.bash_history.tmp && mv ~/.bash_history.tmp ~/.bash_history && history -r
This is an example of what I _believe_ every SRE should master and whatever Post Incident Review (PIR) _should_ focus on. Where did the system fail. What are the missing or incomplete Safety Controls.
@prologic Not sure if the confirmation helps at all. You just condition yourself to immediately press y on a daily basis.

Apart from that, aborting the removal should probably terminate the function with a non-zero exit code, something like return 1.
@lyse I'm open to other suggestions ๐Ÿคฃ But _hopefully_ both adding the additional prompt, not allowing it to enter shell history and removing from my shell history prevents me from doing such silly things in haste by pressing ^R and using fuzzy search which if you type fast you sometimes get wrong ๐Ÿ˜‘
@prologic been there done that with several of my docker volumes to the point of me just not doing docker volumes anymore and manually mounting folders now LMAO
@kate Fair enough! ๐Ÿ˜‚ Also a good approach, change the environment ๐Ÿคฃ