There are lots of existential risks facing humanity which are by definition threats that jeopardize whole humanity with either extinction or deep civilization collapse. They are either natural like super-volcanoes, comets and other cosmic events or anthropogenic as nuclear wars, badly done nanotechnology or artificial intelligence. Some threats can have both origins, like pandemics or climate change. The bad news is that realization of either of these threats can be fatal to humanity. We cannot get used to mitigating such risks. We need to make sure neither one of them occurs. Ever. And those risks that humanity has not thought of yet too. Which sounds like an impossibly difficult task.
Second best thing I can think of is minimizing impact of such catastrophic events. Why pandemics were not humanity-level threats earlier in history? Because there were many populations having little contact with one another for geographical reasons. With advent of global travel we are no longer quarantined, in effect we all live in the same room where one sneeze can kill everyone. But if humanity lived on several planets we’ll be probably risking only one of them if interplanetary travel is taking longer than any disease incubation period. Losing population of the whole planet would be an enormous disaster, but not as catastrophic if it were the only one. Several-planets solution may protect us against planet-size disasters like volcanoes, meteorites, pandemics, grey goo. It won’t likely protect against unfriendly AI. Or gamma-ray bursts if planets are not in distant star systems. Colonizing other planets in a way that these colonies are self-sufficient and capable or reasonable growth still seems like a faraway future. We have plenty of time to die before then.
What can we do before space colonization? What if we ensure that every country is completely self-sufficient even if it continues to use global trade in peace time. Then in case of pandemic, all borders are closed and travel is only allowed into infected states. Chances are, that not all countries will be affected before pandemic is detected and borders are closed. This is not a practical solution though. First, ensuring self-sufficiency will be costly and there is no entity interested enough in achieving it even in its own country not to say helping others. Second, total borders closure is unlikely to be respected. And this solution would have helped only against pandemics, volcanic emissions and nuclear winter know no borders.
Maybe we can have a colony on Earth itself. Like having Fallout game-style vaults, powered by nuclear reactors with fuel supply for the next several thousand years, hydroponics, suspended human embryos to ensure genetic variation in a small community and whatever else that is needed for self-sufficiency. With good enough engineering it can probably survive catastrophic meteorite impacts, nuclear wars and total Earth biosphere collapse. There should always be enough population present in the vaults in case of unexpected event. To be useful against pandemics inhabitants should also have little or no contact with the external world. Which doesn’t sound as an attractive place to be in. We can employ contingent rotation. Like having two connected identical vaults. Each half-year new batch of settlers arrive at the first one. It’s former inhabitants move to the second one. And those who were in the second leave it and return to the surface to live ordinary lives. Something akin to military draft. Sure, it will be costly, but not as costly as army itself and way more useful in ensuring humanity longevity. But there are probably unexpected difficulties in this solution too.
There should also be some other ways to make a humanity backup to ensure that global catastrophes do not wipe us out completely.