generators capable of running whole factory cost lot of money
Yes, but the production process could have been designed with a UPS powered safe shutdown procedure that would avoid destroying 11% of the monthly production run (if it doesn't take longer to restart production from this state).
It would be wise to design factories so that critical parts can be swiftly evacuated in the event that the factory is about to face flood / fire / invasion etc.
It would also be wise not to cluster the manufacturing of one component type in one area of the world.