A sailor survived more than a month stranded in the Pacific Ocean after his mast snapped during a solo voyage.