I can’t restore a password protected sparsebundle

I wanted to restore a password protected sparsebundle from my Time Machine backup. But when I try to restore, the operation can’t be completed because I
don’t have permission to access it. It did succeed in overwriting my old file with something that can’t be opened.

I tried changing my logon password to the password of the sparsebundle and rebooting, but that didn’t work.

So how do I tell time machine or finder or OSX or whatever the
password?

How long do I have to work on this before the backup scrolls off of Time Machine?