Yes, you can use a shell script to take backups of any file just before opening any file. I use this script mentioned by this person below:
Auto-backup your configuration files with Vim—keep your data safe from accidental changes.
I swear, its amazing script i ever used.