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..