If we’re looking at something that can actually shatter Earth, we’re screwed. Pretty much completely. Even a Mars colony might not save the species, something that big will wreck orbits and cause tidal stresses and all sorts of other crap. Our best chance in this case is to start with a distress call- just something a passing ship might notice and investigate, and hope to hell they’ve got some ideas and tech to help us out. Parallel to this, build the largest Orion ship we can, load up the smallest genetically viable founding population we can to crew it, tell them to make babies, and point it at the nearest star that might have an Earth like planet in the habitable zone. And hope they make it, find a habitable planet, and start anew. Chances of failure would be incredibly high, but barring helpful aliens with fleets of FTL transports it’s our best, really only, chance of survival.
Now, as for somewhat smaller scale destruction- wiping out all life on the surface- there might be a few additional options.
A generation ship as in the scenario with Earth actually being destroyed wouldn’t necessarily be a terrible backup plan, but to make the far more plausible Mars attempt work we might not be able to spare the resources. If the resource situation allows, though, the generation ship should be launched.
What’s an Orion ship you ask? Nuclear pulse propulsion. Toss a nuclear bomb out the back of the ship, and ride the shockwave. The basic principles were proven in the 60s, but bans on nukes in space shut down practical research. It’s the only tech we have that can achieve the speeds and load capability to give any of this any chance of working. There are a few ideas discussed in scientific papers that might be better, but we can be sure Orion will work. Will it work well enough? Unclear. But it will work at all, and we can say that with much more certainty than, say, an Alcubierre drive.