The easy method to using burrows to keep the civs safe during ambushes / sieges / and other fun.
1) Define safe burrows. You'll want to cover every *safe* area, including expansion area to start with. I usually have one for the magma forge area, one for the main residence, one for the trade depot, one for the farms, etc. I suggest going with less then 6-10 total burrows. Have a bit of overlap where an outer, less safe, burrow crosses some boundary (usually a drawbridge). The inner, safer, burrow should not extend outward over the bridge, but the outer, less safe, burrow should extend a bit inward to overlap with the inner burrow.
2) When fun happens, go to "m" (military) "a" alerts, and highlight Active/Training in the left column, hit the enter key to move the "CIV" tag down to that one, then arrow over and turn on the "safe" burrows (with an "A" to the right of the burrow). Note: This assumes that you have not created non-standard alerts.
3) All your civilians who are not part of activated military squads will now stop what they're doing (if outside those burrows) and immediately head for the nearest active burrow(s).
4) If the siege / ambush is off screwing around at the borders (in 31.18, ambushes had a bad habit of hanging at the map border for a few seasons), define some outer, less safe, burrows that are near the main entrance and activate them. Now your workers can at least get *some* work done outside the walls, without running all over the map.
The main problems you'll run into:
- Military dwarves like to go and pickup items off the corpses outside the walls.
- Forgetting to extend or add burrows to dig out new areas that you forgot to highlight
I don't bother setting up custom alerts any longer. Having burrows like "courtyard", "farms", "upper walls" (only if there are no enemy archers), etc. is plenty.