I don't have a UPS but everything had surge protectors. I think lightning was a little more than what they were designed for.
Nothing stops lightning, but the surge induced by nearby strikes can possibly be blocked by a (good) surge protector. Close enough, though, and it either fries the stuff directly, or induces enough EMF in the cables and such to do harm. _All_ the cables, including internal ones. -- Jim