I have backed up my Nexus 7 before an upgrade. It was a while ago, but here is the rough procedure...
Unlock the bootloader.
Enable ADB
Start ADB shell on a connected computer
Use the dd command to copy a file system to a file (eg... dd if=/dev/block/mmcblk0p2 of=/sdcard/modemst1.img)
Use the pull command to download the image (eg... adb pull /sdcard/modemst1.img)
On the Nexus 7 there was enough space on the internal storage to copy the partitions that had data in them. I suspect this will work fine with external storage and that can be mounted from a custom ADB interface. No idea if it will work on a stock device default. Also you need an SD card slot.
I hope that gives a few hints. Obviously it is just an image of a filesystem, but it can be used to return your device to a point in history. Looking at the Lineage OS install instructions when the device needs repartitioning is a good thing as this is the recommended backup process.
All the best,
Alistair