Saving UNO R3 16U2 Firmware for Restore

AVRdude has command line options for saving the contents of flash. It only works if the lock fuses aren't programed, I have no idea if they are or not on an Arduino though I'd guess not.
The command would be roughly the following:

avrdude -p (chipID) -c (programmer name) -U  flash:r:filename.hex

With (chipID) replaced with the name of the chip, and (programmer name) replaced with the programmer you're using (USBtiny, ArduinoISP, etc.)
No guarantees that the above line will work without massaging.