Modify flasher script to copy and restore a file?

My BB’s generate a custom config file ( different for each) that I would like to save across a reflash from flasher SD card.

Essentially I want::
Flasher script to copy /etc/somefile from eMMC to somewhere ( SD card or temp)
Flasher on SD card then performs normal flash of eMMC
Finally script copies somefile back to same location it was before

BB come up with new image AND has the same custom file that was there before the flash.

I think this would be useful for anyone wanting to save something like static IP address too.

Any suggestions on best way to achieve this?