If you're in the US, I can't think of anything in the NEC that would allow you to do this for less than a few hundred dollars - legally, that is. When you power mains fed loads from a transferred battery powered source, it's what's called a Separately Derived System (the same as a permanently mounted generator). If you intend to do this, you better read up on the requirements for SDSs. It will mean installing separate grounding electrodes, panels, transfer switches, etc. Big money if you want to do it and have insurance cover a loss if something goes wrong.