Would this work?
Backup off grid inverter wired to breaker box with generator interlock kit. This requires the main switch to be off before you can flip on the breaker that connects the generator (or inverter) to the breaker box.
If power goes off. Flip off main power. Then flip breaker...