Modifying a rig made in Rigify clears the animations
If you regenerate the rig, it generates a new one and replace the previous. But animation data stored separately in Data blocks. So what you need to do:
Open Dope sheet and change its type to Action editor. In the center of the header you will see the data block:

Press Shield icon to make sure, that block will not be removed. And keep in mind the name of it.
Then regenerate the rig and address to action editor again. You will see something like this:

Click on this icon and browse your data block here. Once you are done the animation will be restored.

When you will get familiar with data blocks, you will be able to transfer animations between files and rigs, store different animations for the same rig and mix them together in NLA editor!