mongodb: make sure etc exists before copying.

Fixes #22329.