Oh, that’s actually an issue that I have had before, and I’ve definitely written up a a few bash scripts that download the assets folder and dump the db as a backup. Unfortunately I have nothing to point to as they tend to be quick one-offs.
The issue that I’ve encountered is the the upgrade process can be quite fickle, especially if you’ve got a lot of extensions to get through, and I end up bricking an instance more frequently than I’d care to admit. I don’t know of a native solution to this but I’d love to see an extension or something that downloads and restores the entire filesystem easily, since yes, you can absolutely lose a bunch of data on accident.