Check whether the batteries are all in series, if so then that's 6V. I'd match the voltage to keep things as is.
Might wanna confirm with a multimeter, the cheapest one works for what you need here.
That would allow you to also confirm the current (amps) required when it's idling and when it's operating the flap.
Which then also allows you to calculate how long whatever battery backup would last.
TL;DR: Power supply voltage should match, available amps can be higher or equal.
Then you can just search digikey or whatever electronics retailer you have and order a battery pack for said voltage... which, for 6V, would really just be 5 cells in a wrap.
Alternatively, you might get away with just cramming an extra rechargeable AA in there yourself (5x1.2V=6).
Make sure you don't hardwire a power supply while there's alcaline non-rechargeable batteries in there.
Technically, instead of putting the battery backup in the device it could be on the other end of the hardwire you're takking about doing.
Hell, if you already have a UPS for something else nearby, you could just plug a 6v dc power supply in that.
There's a few ways to go about this.