locking before copy of db