A battery stores electricity and switches on automatically when the grid goes down. Most homeowners never notice the change, apart from the neighbors' windows going dark.
How long it lasts depends on how much it powers. Backing up essentials such as the refrigerator, lighting, Wi-Fi, and select outlets stretches a battery much further than running the whole house, and a smart panel can manage that automatically.