The optimal and universal adopted solution is to store energy in batteries. Being able to get a continuous alternating current based on converting the direct current coming from these batteries in an alternating current of the same features than the commercial mains, but with no breaks.
When all these parts of this solution are fitted in only one equipment, it is the called UPS, which means Uninterruptible Power Supply.
There are different UPS structures, with different technologies of their parts: Off-line, Line-Interactive and On-Line.
The parameter that distinguish the different technologies is if the batteries allows or not that the critical load is supplied by the AC mains directly. In the Off-Line and Line-Interactive technologies, the UPS works on no mains conditions only, meanwhile the On-Line technology case, the load is permanently supplied from the energy that the own UPS generates, in both cases with and without power supply.