Over at the Repair Hub they have a great how to on building a battery backup circuit for your Raspberry Pi computer.
You’ll need to spend a bit of money on the parts and be careful putting it all together as you could end up with a Fried Pi!
If that looks like too much work why not snag a prebuilt UPS for your Pi?