1. Backup all available in twrp
2. Follow this for root ->
http://forum.xda-developers.com/moto-g4-plus/how-to/root-systemless-rooting-supersu-2-74-2-t3405772
3. Download Flashfire ->
https://play.google.com/store/apps/details?id=eu.chainfire.flash&hl=en_GB
4. Set selinux to permissive temporary:
5. Open Flashfire and select RAW partition backup.
(I would backup all, but for IMEI you only need modem partitions)
EDIT: I restored my backup and it's fine now. But I sure did almost have a heart attack. I am on nougat soak test which was causing issues.
I did the second step but now my IMEI doesn't show up anymore, my SIM isn't found, I can't find any networks, my IP address is gone, my mac address is reset. Do I restore the backup?
tl;dr: topic in the second step barely points out the fact it only works on marshmellow (small, non bold, normal size letters at the top of the topic), flashed it anyway, almost lost my IMEI while trying to backup... my IMEI
EDIT 2: sorry for being such a noob, but wouldn't it be better to go straight to CM, root it with CM's built-in rooting functionality and then do the backup? Would there be a higher chance of losing an IMEI number in the process of that than in the process of your instructions because for your instructions I need to go back to marshmellow, root, backup IMEI, flash nougat (people say CM has less issues if you flash nougat first), flash CM? How do you even 'lose' your IMEI?