This is the premise set forth by Neal Stephenson in his excellent novel, Seveneves, a hefty tome of 860 pages that charts humanity's race for survival when Earth's ancient satellite disintegrates.
Without dwelling on the reason behind the Moon's destruction, Stephenson instead focuses on the aftermath. The book is divided into three acts: the global effort to preserve the human race by using the International Space Station as a form of Noah's Ark, the post-apocalypse settling of the surviving community (and all the political / cultural sheananigans that inevitably arises), the period of resettling Earth thousands of years in the future.
Expertly written with some gripping scenes, Stephenson explores the doomsday scenario well and has a good understanding of human nature. Whilst it's no surprise that in the book the whole of humanity pulls together to give life on earth a chance of survival (not just humans, every plant and creature too), the subsequent cracks that appear in society are all-too familiar. That's what creates the drama, I guess. A novel about everyone being nice to each other and getting along spiffingly in the face of impending disaster probably doesn't make a great story. There is political intrigue and conflicts aplenty along the way, all while the remnants of earth are trying to survive in the unforgivingly harsh vacuum of outer space.
Stephenson doesn't shy away from explaining a lot of technical and scientific stuff. This sometimes bogs the pace of the narrative down a bit, though. I'm not great when it comes to complicated descriptions or explanations and when I was struggling trying to imagine how a piece of future tech works, for example, I became easily distracted and lost my grasp on the story. It does, however, feel kind of necessary given the nature of what happens in the book, so I'll just have to submit to cleverer people than me.
The novel feels somewhat uneven as the first two acts take place one after the other (in the same era) and then we jump forward several millennia to see humanity's efforts to resettle their former homeworld. The latter section feels somewhat rushed as there doesn't seem enough space to flesh things out, but this is a minor issue really. It makes sense, but I could see this story being better told as a trilogy where book one tells the story of the building of the ark, book two tells the story of the descendants living in space and book three tells of their return to Earth.
One other slight niggle is the main catalyst for the story. Namely, the demise of the Moon and it's effect on the planet it once orbited: trillions of small meteorites slamming into the atmosphere resulting in earth being burned to a crisp (called the 'hard rain'). The book talks about this happening for a thousand years or so and I find it hard to believe that there are enough 'bits' of the Moon to rain down continuously for such a long time (given that the Moon is about a quarter the size of Earth), but I may have gotten that bit wrong. Also, the fact that no reason is give for the Moon's destruction is a bit unsatisfying.
This is an epic novel (although could have been even more epic given the scope of the story), thoroughly enjoyable and one I would definitely recommend.