Add a persistence backend fetching context manager

Allow the persistence backends to be fetched using a new
helper method that can be used as a context manager, it will
fetch the backend, ensure it's upgraded and upon context manager
exit will close the backend automatically.

Change-Id: I1bf8e43dcce25c02823cca92e3e7ed3ef254a847
Merge "Add a persistence backend fetching context manager"