Create the burrow
Hit w to go to the burrow menu and a to add a new burrow.
Then hit enter to define it.
Hit n to name it, I'd call it "Inside".
Then hit Enter to start a rectangle and enter again to finish it, just like designating areas to dig. Except that you can start on one level and end on another and it includes that rectangle on all of the levels, inclusive. Handy. Make as many rectangles as you need. Note that the burrow symbol will only show in areas that you've dug out, but the burrow will actually extend into the unrevealed rocks, so you can still dig in those areas.
Then hit ESC a couple of times to get out of the burrow menus.
Create the alert
Hit m to bring up the military menus, and a for alerts.
Now c to add an alert and N to give it a catchy name.
Now move the cursor to the far right column, which should have the burrow you just created, and hit Enter to associate that burrow with your new alert. You'll see a green A next to the burrow when you have that alert selected.
Then hit ESC a couple of times to get out of the military menus.
Activate the alert when invaders arrive.
Hit m to bring up the military menus, and a for alerts.
Now move the cursor back to your new alert and hit Enter, and you should see a green [CIV] move next to it.
Congratulations, your civilians are now confined to your burrow.
Watch any civilians who were outside drop what they were doing and come running back inside. Yay.
When the fight is over, come back and select "Inactive" and hit Enter to cancel the alert and let your civilians back out of the burrow.
That's all there is to it.
Note: dwarves will not leave the burrow for food or drink, so your safe room may become a death sentence.
http://dwarffortresswiki.org/index.php/Civilian_alert