When a gem breaks or shatters the spells enchanted inside aren't fully lost, it depends on the spell and how complex or powerful it is, but a decent amount of the time the spell stays mostly intact inside what remains of the broken gem. But casting another spell to scan what remains and copy it might just cause more damage, so it's better to move that spell somewhere safe and try to recover what I can then.