Many scripts print colours with codes like \033[31m pasted everywhere. tput asks the terminal database for the right code instead.
tput setaf N prints the code that sets the foreground colour to colour N for the terminal in $TERM, and tput sgr0 resets all attributes. I’d store them once at the top of a script:
red=$(tput setaf 1); green=$(tput setaf 2)
bold=$(tput bold); reset=$(tput sgr0)
printf '%sOK%s backup finished\n' "$green" "$reset"
printf '%s%sFAILED%s disk not mounted\n' "$bold" "$red" "$reset"
The basic colours are 0 black, 1 red, 2 green, 3 yellow, 4 blue, 5 magenta, 6 cyan and 7 white. tput colors tells you how many the terminal claims to support, 8 or 256 in most cases.
The nice part comes when output goes somewhere that can’t show colour. With TERM=dumb there is no code to print, tput outputs nothing and exits non-zero, and your messages stay plain text.
It doesn’t check whether output goes to a pipe or a log file, though. To keep escape codes out of backup.log, only set the variables when [ -t 1 ] says standard output is a terminal, and leave them empty otherwise.
Further reading: tput(1) Linux manual page, tput man page (macOS)