Entering the following in the console:
Just FYI, it will work if you are using an HD wallet... also, the "dumpwallet" command will give you everything in one go... it will dump the "extended private masterkey" and all the keys/addresses and derivation paths into a text file:
# * Created on 2017-07-27T04:05:43Z
# * Best block at time of backup was 11832 (000000005b9214c4d9d99898611bf43a91ba671f0541d2e50090dd5c410198cf),
# mined on 2009-04-22T04:57:32Z
# extended private masterkey: xprv9s21ZrQH143K43qu96Djj54GS7zzG9uhMmU9gABH7MNmwwMwLQyffoMkabosk1xDcHLfSZV3kUY wKVvovKuDEtzT99XRcBJjtUQ4RiSBaG7
L3aiVXi12rhosNWDzoEfaxUj4nGsD2tti5GHV1yfADxu3DmUcUaA 2017-07-14T00:06:28Z change=1 # addr=115jNSpywutcZWawCKCcMcAAWVctVCXEUh hdkeypath=m/0'/0'/40'
L3bFVw3EXq1PZPzi5AN3i7HZTDkbguA1c6pDa3xDdkZ9qcsauNcq 2017-07-14T00:06:28Z change=1 # addr=172v1xmZS9xci4Zza6CiqQdrdBBF1hQZ5 hdkeypath=m/0'/0'/45'
KwGxZRDUdQdoi9v1tUxwbzt7p7BXj5JpPGNn3ACw16KR8Qv1tuoo 2017-07-14T00:06:28Z change=1 # addr=139kcSJqvr6UJJLWQGXCmuvsRaYbAPuxRH hdkeypath=m/0'/0'/8'
EDIT: Obviously, you will need to take necessary safety precautions... not only with the text file, but in generating it... "dumpprivkey" displays the key in the console... so it exists in memory and on screen, it will only be on disk if it gets paged out of memory... "dumpwallet" dumps it onto a file on your disk in plaintext.
This should not be done without due consideration of the implications this has on your private key security!