copying a sketch from a board

right help if poss, running a mega with a sketch on to control lighting on my fishtank, i want to create a backup mega for it as i got a bit of water onto it, i know at the moment its fine but this is belt n braces approach being a reef tank, its carrying other bits inc three temp sensors, in an ideal world i want to be able to copy whats programmed into the mega due to some the parts being bespoke to the board, like an idiot i forgot to copy the program which included the addresses to these parts ----- is there a way to read,copy and then upload to a spare board ??

thanks in advance

is there a way to read,copy and then upload to a spare board ??

It is possible to read the hex file that was uploaded, and to then upload that hex file to another board. It is not possible to recover the sketch that was used to create the hex file.

One program you can use is 'avrdude' (AVR processor Downloader/Uploader) which is included in the Arduino distribution. You have to run it from a command line and find the instructions for how to do the download.