Fix restore of local db after downloaded prod data

I managed to sneak a half-baked solution through code review earlier.
This one actually works.