Following step you might be follow.
First you have to execute Db upgrade nopCommerce 4.0 script and if you are using third party plugin than you have to execute that script also.
For an ex sevenspike plugins.
After download 4.0 source code and extract it once run these code so, datasetting.json and installed plugin.json file automatically created.
After, your customized code will put one by one from 3.90 to 4.0.
If you have third party plugin and theme than you have to put 4.0 as well.
Connect original db.
Check your all functionality and test.
Don't forget to backup your 3.90 db.
You can get latest code and script from here