Since you want to restart things at the same point they were before getting stopped, I suggest you try and use suspend. Depending on your hardware, it may be easiest to use ACPI suspend to disk, or "Software Suspend 2" suspend to disk, or ACPI suspend to ram.
Any of those is so specific, that you'll have to start another thread in case you have difficulty with either.
Next, you'll want of course to fire the suspend operation in case of power shortage. I have absolutely no experience with that, but I remember seeing something about it in the /etc/inittab file.