Training dwarves for defense hasn't worked out well for me, so here are other things that I have tried so far for survival, with no silver bullet yet:
Training:
Dwarves suck at training up their skills, apparently. It is exceedingly obtuse to successfully to train up combat skills (due to the complicated interface for armor, weapons, squads, and bad defaults for training), and after training, the loss of parts of your squads is likely to cause a tantrum spiral in your fortress due to lost wives/husbands/fathers, anyway.
To even train at all in the slightest, you have to work around a default that the "minimum required to train" is set at 10 by default, so any squad with less that the absolute maximum will not do anything but the most basic of "individual training".
Danger room:
Complicated to set up, have not got this to work yet.
Dogs:
I have not seen a great effectiveness in assigned war dogs as protectors for dwarves, though the benefit is hard to gauge in the heat of combat while your dwarves are dying. No silver bullet.
Traps:
Stone fall traps are generally insufficient defenses. Cage traps are great, but slow to build and require wood. Weapon traps are tricky due to using up your weapon stores that your dwarves would otherwise use themselves.
Moats & Walls:
Both moats and walls are great obstacles for invaders, but will conflict with traders getting to your depot to trade with you. Also note that a moat, while being the easiest to build by digging a double downward channel, allows goblin archers that come to pick off your dwarves across it. You can use a labyrinth approach with traps to work around that problem, leaving a winding corridor of untrapped space for your traders to wind through, while invaders will be unable to see the traps and will run right into them. Here's a simple example of what I mean by a labyrinth corridor, which invaders will go straight through while traders follow the untrapped path of:
M=Moat or otherwise impassible area
T=Traps
M M
M M
M M
M MMMMMMM
M M
M M
M M
M M
MTTTTT M
MTTTTT M
MTTTTT M
MTTTTT M
M M
M M
M M
M TTTTTM
M TTTTTM
M TTTTTM
M TTTTTM
M TTTTTM
M M
M M
M M
M M
MTTTTT M
MTTTTT M
MTTTTT M
MTTTTT M
But even a labyrinth approach like this the traps have to be super effective to stop the invaders entirely.
Drawbridges:
When put over a moat and then retracted, these will stop invaders quite well. Unfortunately, when the invasion happens, getting a dwarf to pull the lever to retract the drawbridge is often like herding cats. Bloody, hissing, scared cats. So having one or two of these over an impassible moat is good, but they won't be enough on their own.
Just "Cask of Amontillado" wall everyone in
At the moment, this is the approach that I will probably be pursuing, though I don't have all the details like how to obtain wood or migrants or whether to care about trade figured out yet.