Upvote:7
How battle damage was repaired was essentially a matter of where the damage was and how much of it there was.
With wooden warships during the Age of Sail, the main sources of battle damage were impacts from cannon balls and damage by fire. Both of these were usually concentrated above the waterline. Depending on the type and range of engagement, it was possible for ships to aim "between wind and water" (which is the part of the ship's hull that was exposed and then covered by water as the ship pitched and rolled in the seas) but given the accuracy of cannon of the period hits on this area were comparatively rare. Damage well below the waterline was potentially possible if the ship was heeled over and struck by shot but significant structural damage below the waterline was typically the result of running aground.
Even without engaging in battle, wear and tear on the ship's hull meant that the ship's crew would be experienced in running repairs and replacing hull timbers. While wooden ships were structurally weaker than the later iron and steel replacements, their method of construction (essentially timbers, nails and rope) meant they were easier to repair.
In terms of materials, wooden ships usually carried a supply of spare timbers, rigging and fittings. So minor battle damage, especially where it was above the waterline, could be repaired without needing to return to port. If you had the advantage of capturing a prize during the battle then stores (timbers, spars, tackle, rope, etc) could be scavenged from that vessel to repair your own. Alternatively, other ships in your fleet or squadron would share these materials.
For more substantial damage, the ship would return to a naval base or port with repair facilities. If it was significant enough and the ship large enough (especially if there was damage below the waterline for whatever reason) then it would be taken into a dry dock. The water would be pumped out and the ship's hull could be repaired directly. Smaller vessels could be repaired by beaching them.
In extreme cases, where the structure was significantly damaged, it would often be the case that the ship was completely dismantled. The owners would then have the option of rebuilding the vessel (possibly including alterations such as changing the shape of the bow or stern, or extending the hull) or using the timbers to repair or complete other vessels.
The costs of dock repairs and the time taken could be significant. Taking a famous example, HMS Victory, the ship experienced 23 dock visits during its working life (and several more since it left service). The shortest of these was 3 weeks and the longest, at 39 months (in 1800-03), was essentially a rebuild which cost more than the original cost of construction.
Additional Reading:
Fighting at Sea in the Eighteenth Century: the Art of Sailing Warfare, S. Willis (2008)
Nelson's Navy: The Ships, Men and Organisation 1793-1815, B. Lavery (2009)
The 100-gun ship Victory, J McKay (1987)