NotATether's sollution works...
If you want an easyer method that allows you to greatly simplify the backup procedure, you could also use electrum, let it generate a seed phrase, write down this seed, then go to electrum's console and do:
wallet.change_gap_limit(10000)
wallet.storage.write()
listaddresses()
Then you'll get a list you can import into a db.. Do prepare to wait a LOOOOOONG time... A 10.000 gap limit isn't small...
TBH, my sollution isn't per defenition better than NotATether's, it's just differrent

Not best option, because
1. Electrum wallet isn't scalable (one of the reason is usage of JSON to store the information).
2. Electrum server maximum request for each user.
The only reason I can think of why someone would need millions of addresses is spam/scam/extortion email, where you'd like to keep track of who paid you.
I doubt it's practical, the percentage of people who fell to such email is very low (but high enough to remain profitable). It's easier to use static address and ask the victim to send email which contain TXID.