Here’s a suggestion. Add a diode connected to the input filter cap so a 12V (or similar) DC supply could be used to keep the PI from crashing (and possibly corrupting the SD card) when the power goes out. I have thought of various ways to do this and the current plan is to use the unused wires in the ethernet cable to run 12VDC from the router area to OSPi. The 12V supply will come from a standard UPS that is running my routers and such. If it’s a long outage I can send a command to the pi to shutdown before the batteries run out.
All that’s needed is a diode and an input terminal. If you brought out the cap terminal too it would make a battery module hookup possible with charging. Or just put one terminal from the cap and the diode or whatever else could be put on the external circuitry.