How do some species of bacteria survive bad conditions?

They survive by forming a thick protective coating around themselves. They are then known as spores. Inside the spore the bacteria cell becomes dormant and may remain there for a long period of time.