This works for Mint, ought to work for Ubuntu...
There is a way to avoid "having to reinstall everything" if you do it before a system is damaged. There's a tool called Timeshift, which ships with Mint by default and can be apt-get installled for Ubuntu. It is designed for system files mostly, you make a backup image (on an external drive or a spare HDD partition, must be an ext4 partition, can't save on FAT32 or NTFS, can't compress in to zip/7z/tar files either), and can restore to it later if your system is damaged. With some sketchy methods you can also get it to clone all your installed programs, even installed under Wine and such, and user settings files in various home folder subdirectories. I use this technique, with the fiddly additions to clone some home diretory stuff too, to make system images I can use to restore to. And the same system image can also be loaded on to a different PC, so long as you tinker with some UUID values once on the new system so it recognises the new hard drive rather than trying to find the original one.
In the case of fixing a corrupted system it may even be able to identify just those files changed (including deliberately changed, but also corrupted ones) since you made the Timeshift image and replace those with old working copies.