In the sport of boxing a fight lasts for several rounds separated by a short interval for the fighters to rest and lick their wounds. The end of each round is announced by a bell so if you are in difficulty towards the end of a round then you will be saved by the bell because then your opponent must stop hitting you.

or

Buried alive. Anyone's worst nightmare. There was a strange disease in the 1500's that would slow one's heartbeat and breathing enough that upon inspection, the afflicted person would indeed seem quite dead. When England began to run out of room to bury recently deceased people, they dug up the coffins of people who had long been deceased, removing their bones from the coffins and placing them in a bone house and re-using the gravesite.

When opening the coffins of long ago buried bodies, they noticed that 1 out of every 25 coffins had scratch marks on the inside. The town folks had been burying people while they were still alive.

To avoid anymore people being buried alive, a string would be tied to the wrist of each corpse, threaded through the coffin,up through the ground, and tied to a bell.

Someone would have to sit in the graveyard all night and listen for the bell to ring, just in case the corpse was not really a corpse.

Hence the phrases: Saved by the bell, Dead ringer and Graveyard shift. This website casts doubt on whether the phrase was ever actually used in connection with burials. http://www.phrases.org.uk/meanings/saved-by-the-bell.html