This comes from the Latin word barbarus meaning foreign. “Barbary” referred to foreign lands (lands not of ones own). And “barbarian” referred to the people who lived there.
The northern coast of Africa was named “The Barbary Coast” by English speakers after attacks from pirates based in Tripoli and Tunis. The young United States fought two series of battles with these pirates in the early 1800s, including the first ever foreign action of the U.S. Marine Corps.
The ancient Romans named the inhabitants of Northern Africa “berbers,” a form of the word “barbary.”
Since barabas is a relative term (“foreign” to whom?), once has to assume that no one ever referred to themselves as “berber” or “barbarian.” It seems to be a mildly pejorative term used to describe other people.
Why I Looked It Up
I read Thomas Jefferson and the Tripoli Pirates which referred to The Barbary Coast quite often.
(Humorously, I also remember Gonzo in Muppet’s Treasure Island saying he wanted to “travel to Zanzibar to meet the Zanzibarbarians!” With all due respect to Gonzo, a resident of Zanzibar – an island off the coast of East Africa – is a “WaZanzibari,” not a “Zanzibarbarian.”)