Well, traps are a highly effective defense. My standard embark channels the edges with a 'wagon only' channel and leaves one point where everything else has to walk through. I call that point my "welcome center" it consist of a small room with 4 entrances attached to the perimeter channel. Each entrance is a hatch cover linked to a pressure plate with the pressure plate non-citizen triggered, any weight. Effectively, that makes all of the entrances one way for enemies. I use 4 of 'em so as to provide as much opportunity as possible for entire squads to get inside the room before panicking and fleeing (means that there's usually one or more entrances available while the most recently used ones are waiting for the pressure plate to reset so the hatch cover will close and make it pathable again. Then only usable exit from the room leading to the surface then passes through a goblin grinder filled with traps. Just in case a creature is standing on a hatch when it opens, I have a tunnel that passes under each hatch that leads back to the unsecured edge at one end and up to the room at the other so it doesn't provide any pathing to my fortress. That tunnel is filled with cage traps. Finally, I have a drawbridge connected to a lever that when closed blocks off the 4 entrances to the room. The only thing that can get through as kobold thieves and fliers. Everything else either gets killed in the grinder, or trapped in a cage for later looting and execution. Whenever I get a siege, ambush, mega-beast, etc, my procedure is.
Call a civilian alert restricting all dwarves to a burrow that on the surface is every more than 21 tiles away from the channeled edge. One level below the surface, everything no including the channel at the edge, and finally below that, everything. The 21 tile limit is to keep enemy crossbows from killing any dwarves on the surface. And because of the burrow restriction (which /doesn't/ include the goblin grinder or anything in the welcome center) they don't go cleaning out any jammed traps just because something go stuck in 'em. If figure that 15 or so single weapon weapon traps in a grinder can tolerate a few of 'em getting jammed. As for the cages, I've got about 60 of 'em in the tunnel underneath (I thought that the 25 or so I had originally was overkill.... Until I got a siege with 8 squads and 10 orgres).
Then watch the welcome center. When a building destroyer gets close, throw the lever closing the drawbridge and protecting the hatches (and at the same time encouraging the building destroyer and associates to enter the tunnel filled with cage traps).
I may open and close that bridge a few times. If I have some enemies in the entrance room of the welcome center frantically attempting to leave, I'll close the bridge to 'encourage' 'em to either go through the cage corridor underground or step into the grinder and be killed. After the room is empty of live enemies, I'll open the bridge again (when closed, invaders can still path through the cage corridor underneath the welcome center, but I don't want all the cages to get filled. If that happens, some of the enemies might escape.)