How can bacteria survive harsh conditions?

With the help of endospores, or thick-walled structures that help the bacteria survive harsh conditions.