For that you can use the export/import capabilities from opam switch:
opam switch export <yourfile>
opam switch 4.06.0
opam switch import <yourfile>
If you want some of the packages not to be imported, just modify the import file, it is very straightforward.