[Android Apps and Games] Jephie:
Well, I don't think all of this is applicable to your question, because what I have is Lollipop on Redmi 3, MIUI 7 or so and WhatsApp 2.19.76 - while you're talking of newer, more restrictive Android, if I understand correctly.

However, for what it's worth, here's what I have done, as per what WhatsApp-Key-DB-Extractor-master/WhatsAppKeyDBExtract.sh has in it and my understanding of using ADB shell vs issuing commands from "outside" of Linux shell:

Yep, no problem, except it said

So,

shell@ido:/ $ pm uninstall -k com.whatsapp

it was.

Well, that wasn't in the .sh script, only in your "manual method" link, which I've only seen today, so I didn't do that.

The result was (adjusting for my "manual" paths):

shell@ido:/ $ pm install -r -d sdcard/WhatsApp-2.11.431.apk
pkg: sdcard/WhatsApp-2.11.431.apk
Failure [Invalid apk]

(which the .sh script downright ignored, at which point I stopped trusting its error-checking).

About "Invalid? Has your download broken?" - I got it off 3 different sources, the two mirrors in the script and a WaybackMachine copy of the original WhatsApp's website's pack. MD5 insists they are all exactly the same.

When I did manually ignore the failure and went on to backup regardless:

...the backup failed every time, giving a zero-sized file, whether I tried it from inside an ADB shell or using the "adb something-something" syntax.

So, of course, the rest of

was not applicable.

My question is, actually, slightly different.

I have that Redmi 3, running near-pristine Lollipop and MIUI 7, WhatsApp 2.19.76. Or, rather, a friend has it. A while ago I borrowed it, for the purposes of using WhatsApp out of town. I've discovered "Second Space" functionality, set up camp in Second Space so as to be least intrusive and set up WhatsApp to be "Used in both spaces".

After I returned, the phone went back to its rightful owner and went back to its happy Internet-free life.

Fast-forward a year. I find that some contacts are only to be found and contacted through that WhatsApp history, but the owner is set on keeping the phone Internet-free and update-free (and, as we all know, the latter depends heavily on the former). I agree with them, really (since the phone is only used for SMS, rare phone calls and taking photos, battery life is valued over newest graphics and really doesn't need all that "update" egg-shell-walking), so I decide to pull that WhatsApp history off and put it onto WhatsApp running on an Android emulator or something.

Running WhatsApp gave a "Sheesh, you should've updated a year ago, September 2019!", so I've set the time to a manual "May 24 2019". Then unchecked the "Automatic timezone" and WhatsApp had finally agreed that it's a year ago and it can show me the interface without covering it with the "Update now" overlay. Good. WhatsApp.upgrade is still in the WhatsApp directory, timestamped June 24th, but it doesn't seem to matter, thankfully.

I've done a backup of the sdcard/WhatsApp folder. Then I've done a WhatsApp's "local backup" routine, just for good measure, and gotten a second copy of sdcard/WhatsApp folder. Nice to have enough computer storage to do such things!

Along the way I've found that WhatsApp lives in a myriad of places (probably most of them links, but ADB doesn't know that?)

presumably_second_space_backup_23062020/sdcard/WhatsApp
presumably_second_space_backup_23062020/storage/sdcard0/WhatsApp
presumably_second_space_backup_23062020/WhatsApp
presumably_first_space_backup_23062020/mnt/sdcard/WhatsApp
presumably_first_space_backup_23062020/mnt/shell/emulated/999/WhatsApp
presumably_first_space_backup_23062020/sdcard/WhatsApp
presumably_first_space_backup_23062020/storage/sdcard0/WhatsApp
presumably_first_space_backup_23062020/storage/emulated/legacy/WhatsApp

I think what I need is this sort of thing

sdcard/WhatsApp/Backups:
chatsettingsbackup.db.crypt1 statusranking.db.crypt1 stickers.db.crypt1

sdcard/WhatsApp/Databases:
msgstore-2019-05-24.1.db.crypt12 msgstore-2019-07-26.1.db.crypt12 msgstore-2019-07-30.1.db.crypt12
msgstore-2019-07-23.1.db.crypt12 msgstore-2019-07-27.1.db.crypt12 msgstore.db.crypt12
msgstore-2019-07-24.1.db.crypt12 msgstore-2019-07-28.1.db.crypt12
msgstore-2019-07-25.1.db.crypt12 msgstore-2019-07-29.1.db.crypt12

"2019-07-xx" ones are probably auto-backups, "2019-05-24" is, I believe, my manual backup effort, so I think I'm looking at the right folder (and, hopefully, the right "Space", though I've done the dance on both "Spaces"). Anyway, there are probably only 2 unique sets - mine and owner's, mine being far bigger in chat log size of the two)

After failing to get the key off using "adb backup", I've tried to re-install the original WhatsApp.apk to where it was - since the owner needed the phone soon and I'd rather keep things as close as they were originally.

shell@ido:/ $ pm install -r sdcard/WhatsApp/WhatsApp.apk

Failed miserably:

|shell@ido:/ $ pm install -r sdcard/WhatsApp/WhatsApp.apk
pkg: sdcard/WhatsApp/WhatsApp.apk
Failure [INSTALL_CANCELED_BY_USER]

"USB debugging" is "On", "USB debugging (Secure)" is, I believe, not needed. Occasionally I see on the phone screen the notification that, I (or the phone?), indeed, had not allowed installing something through the wire and should turn on USB debugging. I'm hazy on the details, since it only flashes for half a second - not enough to read, nor to pull down the notification curtain.

Since then I've seen people say that "MIUI optimisation" might be the culprit of INSTALL_CANCELED_BY_USER when user didn't do anything, not even see any requests - haven't had a chance to try.

So I think that I can install it from the phone itself (and read somebody's suggested, but not accepted "quick hack" to the same effect. It wasn't accepted because the asker needs to install the software-in-development many times and really needs automation - I, on the other hand, don't care).

Double-tap, install, launch... "Welcome! Please give us your phone number for verification!"

When I went to First Space, the owner's WhatsApp launched normally, giving valuable information about MIUI's Second Space internal workings - it does copy the whole lot for independence purposes! Why the Camera pictures end up shared between Spaces anyway, I haven't the foggiest.

Here comes my actual question (and kudos to whoever actually gets this far!). I can give it the same phone number as before, get the SMS on my own phone, type it in, no problem (knock on wood).

However, there was something somewhere about "if WhatsApp sends confirmation message, it generates a new code/key/something-or-other and this is will play havoc with decrypting later backups". As I understand it, a new confirmation code might mean a new key, possibly killing my chances of decrypting old backups. Or making the old ones incompatible with new backups. Or something.

I don't have any other backups to merge with, per se, now that I think about it, but

1. I'm not sure that confirming phone number on the phone won't give trouble to my Android VM when I confirm phone number for its install (and Android VM will probably want a new WhatsApp version, I doubt I'll be able to cut it off from the 'net - particularly when I actually try to make contact with whoever the whole thing started for!)

2. I'm not sure that confirming phone number on the phone won't forever kill my chances of getting that old key. And with it, potentially, my chances of decrypting those backups. How backwards-compatible are WhatsApp backups/logs? A very old version, I believe, just generated the same key whenever the same phone number was used (basing key on phone number), is that still true?

What is the best course of action? Try to re-install 2.19 on phone again? A new trick for forcing 2.11 to install on phone again? Go to VM and try to make that work, leaving the phone's WhatsApp to the dogs? Any way of actually getting that key? So far I'm leaning towards "Confirm phone number on VM and hope that it'll both ask to restore backups and actually manage to do it", but I don't want to cut off options by doing that.