also handle-bar, 1867 in reference to bicycles, from handle (n.) + bar (n.1). Handlebar mustache is from 1932, American English, from similarity of shape; the comparison, if not the phrase, dates to at least 1911.
Old English handle "a handle" (plural handla), formed from hand (n.) with instrumental suffix -el (1) indicating a tool in the way thimble was formed from thumb, spindle from spin, spindle from spin, ladle from lade, etc. The slang sense of "nickname" is first recorded 1870, originally U.S., from earlier expressions about adding a handle to (one's) name (1833), that is, a title such as Mister or Sir. To fly off the handle (1833) is a figurative reference to an ax head (to be off the handle "be excited" is recorded from 1825, American English). To get a handle on "get control of" is recorded by 1919.
late 12c., "stake or rod of iron used to fasten a door or gate," from Old French barre "beam, bar, gate, barrier" (12c.), from Vulgar Latin *barra "bar, barrier," which some suggest is from Gaulish *barros "the bushy end" [Gamillscheg, etc.], but OED regards this as "discredited" because it "in no way suits the sense."
General sense of "anything which obstructs, hinders, or impedes" is from 1530s. Of soap, by 1833; of candy, by 1906 (the process itself dates to the 1840s), both from resemblance of shape. Meaning "bank of sand across a harbor or river mouth" is from 1580s, probably so called because it was an obstruction to navigation. Bar graph is attested from 1925. Bar code first recorded 1963. Behind bars "in prison" is attested by 1934, American English. Welsh bar "a bar, rail," Irish barra "a bar, spike" are said to be from English; German Barre, Danish barre, Russian barŭ are from Medieval Latin or Romanic.