Extract database dumps to function

There was duplication between base and target dumps that is resolved
by use of arguments.

By extracting to function it becomes easier to make changes to how
database dumps are performed. The current setup is a bit hairy,
aggregating in a function makes it easier to improve later.

Change-Id: Ic5d4f13eaa7a4d842c9af0073de17e1cffad0a88
Merge "Extract database dumps to function"