Preserve Key Pair on Node code update

I am developing a network of nodes with libp2p on Go. As I am using GenerateKeyPair to create the node key pair. I understand I can use peerstore to preserve this key pair when the node is restarted.
But I also want to preserve the key pair when I update the node’s version (by downloading and installing a new version of the node executable). In this case, I assume peerstore will be recreated so it will be empty.
Can anyone suggest what is the best (security-wise) strategy to preserve the key pair on a node code update?