As root, just cat the partition to another partition: cat /dev/sdXn > /dev/sdYi
or to a file: cat /dev/sdXn > backup.img
Or to a file or partition on another machine: cat /dev/sdXn | ssh user@host 'cat > backup.img'
You could use dd instead of cat, but there's no good reason to do so:
dd if=/dev/sdXn of=backup.img
Or if you want a progress bar while it's copying and/or control over how much buffering is used during the copy, you could use pv:
pv /dev/sdXn > backup.img
If the partition has read-errors, you might want to use ddrescue instead of cat:
ddrescue /dev/sdXn /dev/sdYi
or
ddrescue /dev/sdXn backup.img
ddrescue won't write to stdout (or read from stdin, either), so if you want that backup.img on another machine, you'll have to copy it (e.g. with scp) afterwards, or write it to an NFS mount.
Or, as mentioned by user1133275 in a comment, you could use process substitution:
ddrescue /dev/sdXn >(ssh user@host 'cat > backup.img')
Finally, if you want a compressed, mountable filesystem you could use qemu-img:
qemu-img convert -c -O qcow2 /dev/sdXn backup.qcow2
To mount it:
qemu-nbd --connect=/dev/nbd0 /path/to/backup.qcow2
mount /dev/nbd0 /mnt
Both qemu-img and qemu-nbd are in the qemu-utils package. BTW, if you took an image of the entire disk rather than just a partition, you could run your old system as a VM in your new system.
Another alternative is just to install a second disk and install the Debian 10 on that. Then you can just mount the old drive somewhere on the new system. Or even dual-boot between Debian 9 and Debian 10.
Personally, I would recommend a file copy (e.g. with tar or rsync or even cp -a) rather than an image backup. It's more useful, can be extracted easily to anywhere you want, and doesn't waste space or time copying empty or unused sectors.
image backup are (almost always) the worst way to backup a filesystem.