Not a true story. According to Perplexity:
"Barry Lyndon" is not a true story, but it is inspired by historical events and figures. The film, directed by Stanley Kubrick, is based on the 1844 novel "The Luck of Barry Lyndon" by William Makepeace Thackeray. The novel itself is a picaresque tale that follows the rise and fall of an Irish adventurer named Redmond Barry, who later assumes the name Barry Lyndon[2][5].
Thackeray's novel was inspired by the real-life story of Andrew Robinson Stoney, an Anglo-Irish adventurer known for his gambling, dueling, and social climbing, whose attempts to ascend the social hierarchy ended in failure[1][6]. However, the character of Barry Lyndon and the specific events of his life are fictional.