Telegraphy is the obvious answer for the second half of the century; unlike submarine cables, laying a wire from shore lifeboat station to an isolated light or even a multi-anchored lightship was relatively straightforward. But I suspect that's too simple an answer for what you're asking, and after all, telegraphs did fail. Commons (UK Parliament) command paper C. 5125, The Report of the Committee Appointed by the Board of Trade to Inquire into the Desirability of Electrical Communication between Light Vessels and Outlying Lighthouses and the Shore ... in 1887 tried to tackle this for the most difficult cases, in an era when shipping volume and speed were rapidly on the increase and demanded faster response times. Appendices on page 125 forward talk about methods of signalling when telegraphic lines were damaged or not installed, or presumably before they existed. On page 97, paras 3048-3050, you can see an example: by day, flags are used, and by night, rockets according to the standards set by the Board of Trade. Presumably other nations had similar kinds of standardization, although as long as a certain light station and shore station could convey meaning that was the critical thing. Of course, if neither worked or was visible on the shore, and this sometimes happened, the lightkeepers could only watch the disaster unfold and hope someone eventually received the message.
Although it was theoretically possible to signal the shore using the lighthouse itself, I'm not aware of this being done. They had a lot of eventualities laid out, but nothing had the power of a wire to carry code or voice at the end of the century of course--and wires were vulnerable to conditions and wear whereas wireless would not be so much, which explains the speed of adoption at the start of the 20th century of the latter.