Use global variables in db_sync

Neaten things up and reduce confusion by using global variable names.

Change-Id: I3007514ae286ce56589097594e0090f43407b67c