The real solution, the one used in the oil field offshore, is the correct one for this problem.

Utilize the refinery feedstock to run a sufficiently large generator. Every one of these plants utilize natural gas - many already generate their own power. As every single one of these plants has rail access, even coal could be used to power a local, refinery specific generator setup.

But when a plant is inundated with 10-20 feet of water, then there are other issues. Doesn't matter then if it is local power or not - repairs must be completed first.

Offshore platforms generate their own electricity from the natural gas available at the site - they do not rely on shore-based power. This includes those that send in neatly dewatered and partially refined streams of product. Thus this is already something that is common in the industry.

"Offshore platforms generate their own electricity from the natural gas available at the site - they do not rely on shore-based power."

They do this because they have no choice.  It's frickin' expensive.

If power outages at a refinery are frequent then there may come a break-even point where it becomes cost-effective to have onsite power generation.  But at that level a smart manager will begin to question whether the refinery should just be relocated.

You already have lots of peak power gas turbine powerplants. It is clearly a lot less expensive to move one of those powerplants to a refinery then to move a refinery since a refinery is an order of magnitude more complex and also larger.

You do not have to run the local powerplant 24/7, start it up when you expect the power feed to fail or after it has failed to start up the refinery withouth waiting for external power.