Survival in Crusader Kings is often very difficult but here are a few helpful tips:
The Island Fortress: Capture A island province (The Isle of Man is perfect for this) well away from your home but not near people not of your religion. Upgrade everything to the highest level possible. Even if everything else goes bad,your fortress with a completely absurd garrison size will remain yours for all of the game unless you make a mistake like Ganvelkind succession or you give it away.
Shield: Capture a province near a powerful nation (Lubeck or a province like Capua are good for this)give it to a family member but not your heir. This province should soon become part of either the HRE or someone like England and be protected by them from the outside. Make it a county so he is a vassal of a duke and can't be attacked without attacking the overlord. Therefore if everyone else dies or your titles are lost,you still have someone to play as.