Fix a problem with the initial datasync system.

Now it iterates through the results of large queries with cursors,
so as to avoid datastore timeouts.