Embed lock, and add whole-db copy method