A few years ago I wrote a very long post on the sources and composition of Daniel that I never finished, so here is some of what I wrote on ch. 4, particularly with respect to the sources pertaining to Nabonidus.
The oldest source we have is Nabonidus' own inscription in the Harran Stele (NABON H 1-2). Here the king states that he completed repairing the temple for the god Sin in the Assyrian city of Harran (which had been destroyed by the Medes in 609 BC), and at the request of Sin "I removed myself afar from my city of Babylon on the road to Teima", where he lived "in the seclusion of tracts far distant and secluded" for ten years until Sin called for him to return "at the appointed time" ('adannu, cf. the use of 'iddan in Daniel 4:22 to refer to the duration of time the king would be removed from society). It is also worth noting that the LXX version of Daniel 4 (which is not based on the MT text type but which represents an altogether different version of the story, as is also the case with ch. 5-6) states that the king was "banished to a desert place (topon erémon)", a wording that recalls the desert exile of Nabonidus. Another interesting detail is that Nabonidus claims that his actions were motivated by commands from Sin which he received at night during a dream: "In the night season he caused me to behold a dream, (saying) thus: 'E-hul-hul the temple of Sin which is in Harran quickly build, seeing that all the lands are very committed in your hands' " (I.11-12). Then, when the appointed time came for Nabonidus to return from his self-imposed exile to Babylon, another dream came "in the night season" that "was disturbing" (III.3). In Daniel, the plot turns on the king of Babylon receiving divine dream visions as well.
Subsequent to this, the Nabonidus Chronicle notes that from his 7th to his 11th year, the king remained in the desert in Teima, Arabia, and because of his absence, the traditional New Year festivals and processions involving the gods Nabu and Bel were not performed. There is a large lacuna in the text between the 11th and 17th years, so Nabonidus was probably absent for an even longer time. Although the Chronicle does not explain why Nabonidus abandoned the capital, the Verse Account of Nabonidus (written by Babylonian priests opposed to Nabonidus) explains that Nabonidus had made an image of the Assyrian moon-god Sin and tried to force the populace to accept it. This image was widely regarded as an abomination and a sacrilege (whose appearance would transform into that of a demon when the king worshipped it), and Nabonidus declared that he would cease all festivals, including the hallowed New Year festival, until the temple for Sin was finished. For the priests of Babylon, this was an intolerable insult to the traditional gods. Then Nabonidus dropped everything and entrusted his responsibilities to his firstborn son (i.e. Belshazzar), and left Babylon with an army. Eventually, he came to the oasis town of Teima in Arabia, killed its governor, and took up residence there. The Verse Account depicts Nabonidus as lawless, blasphemous, unstable, and quite mad, whose erratic behavior brought the kingdom to its knees. It ridicules Nabonidus for falsely claiming divine knowledge: "I am wise, I am knowledgeable and have seen hidden things ... Ilteri has given me revelations; he has made known to me everything". He even boasts of being wiser than gods like Anu and Enlil, a claim that would be construed as completely idiotic. In Daniel 4, it is Daniel himself who is proclaimed by Nebuchadnezzar as possessing this kind of knowledge, that "the spirit of the holy gods is in you and no mystery is hidden from you" (v. 9). In contrast to Nabonidus, the Verse Account construes Cyrus as the blessed deliverer who took charge of the kingdom and reversed Nabonidus' neglect. As a polemical piece of religious propaganda from the sixth century BC, it probably represents a popular reaction to Nabonidus' behavior and has a number of points of contact with Daniel: (1) the story of Nebuchadnezzar's installation of an idol in ch. 3 and forcing everyone to accept it, (2) the insanity of Nebuchadnezzar in ch. 4 and his withdrawal from the city for several years, and (3) the motif of the blasphemous king in ch. 7-11.
Among the Dead Sea Scrolls was discovered a "missing link" between the sixth-century BC stories about Nabonidus and the second-century BC story about Nebuchadnezzar in Daniel. The Prayer of Nabonidus, tho fragmentary, relates a story that clearly derives from traditions about Nabonidus' self-imposed exile in Arabia:
"The words of the p[ra]yer which Nabonidus, king of [Baby]lon, [the great] king, prayed [when he was smitten] with a bad disease by the decree of God in Teima. [I, Nabonidus, with a bad disease] was smitten for seven years and since G[od] set [his face on me, he healed me] and as for my sin, he remitted it. A diviner who was a Jew fr[om among the exiles came to me and said]: 'Proclaim and write to give honor and exal[tatio]n to the name of G[od Most High,' and I wrote as follows]: 'I was smitten by a b[ad] disease in Teima [by the decree of the Most High God]. For seven years [I] was praying before the gods of silver and gold, [bronze, iron], wood, stone, clay, since [I though]t that th[ey were] gods.... [text incomplete] .... I was made strong again ... from it he caused to pass. The peace of [my] repose [returned to me].... my friends. I was not able... [text incomplete]" (PrNab, 4Q242, lines 1-8ff; translation by Peter Flint).
Here the king in question is Nabonidus and he is described as residing in Teima, Arabia, just as stated in the Harran Stele, the Nabonidus Chronicle, and the Verse Account of Nabonidus. But this pseudepigraphon more closely resembles the story in Daniel 4.
(1) The original Babylonian accounts concerning Nabonidus describe the king as mentally unstable but do not mention any physical affliction he experienced. In the LXX of Daniel 4:30b, Nebuchadnezzar describes his debasement as not only mental but also physical: "My flesh and my heart were changed".
(2) In both cases, the king had been divinely afflicted as punishment for sin. In the original sixth-century BC story, the king was sinful by neglecting the other gods and worshipping a foreign god. In the Prayer of Nabonidus, the king sins by praying to idols, "gods of silver and gold ... wood, stone, clay". In the version of the story in Daniel, the king sins by failing to recognize the Most High as the source of his power. The motif of divine punishment is explicit in the Prayer of Nabonidus and Daniel 4.
(3) In Nabonidus' own autobiographical account, the length of time he isolated himself was ten years, while the Prayer of Nabonidus and Daniel both mention seven years.
(4) The Prayer of Nabonidus mentions an anonymous Jewish diviner who helped heal Nabonidus, which corresponds to the figure of Daniel in 4:5-6, 15-16. Jews played no role whatsoever in the original Babylonian stories.
(5) The diviner instructs Nabonidus to "honor and exalt the name of God Most High" in order to be healed, just as Daniel tells the king "to atone for your sins by almsgiving and for your iniquity by mercy to the poor" in Daniel 4:24 (MT). It was Nebuchadnezzar's failure to exalt God that led to his predicament in the first place. In 4:33 LXX, an angel tells the king "to serve the holy God of heaven and give glory to the Most High" in order to be healed.
(6) Although the text is incomplete, the very fact that God "remits" the king's sin indicates that Nabonidus did indeed supplicate the Most High in the Prayer of Nabonidus. In Daniel 4:34 LXX, the king states: "I confess to the Most High and I praise the one who created the heaven and earth and the seas and the rivers and everything in them. I confess and praise, because he is God of gods and Lord of lords and Lord of kings".
(7) In the Prayer of Nabonidus, the portion describing the king's restoration is very fragmentary: "I was made strong again ... from it he caused to pass. The peace of [my] repose [returned to me].... my friends..." But it does resemble Daniel 4:33: "At that time my reason returned to me and my honor and splendor were returned to me for the glory of my kingdom. My companions and nobles sought me out, and I was reeestablished over my kingdom".
(8) The unnamed Jewish diviner instructs Nabonidus to "write and proclaim" his confession and in the Prayer of Nabonidus, the king writes his confession in the first person, "I, Nabonidus, was smitten with a bad disease....I was smitten by a bad disease in Teima". In the MT of ch. 4, Nebuchadnezzar writes a letter to "all peoples" stating his faith in "the Most High God" (cf. 3:32-33), and which describes his experience in the first person, "I, Nebuchadnezzar, was at ease in my palace" (4:1), "I, Nebuchandnezzar, lifted my eyes to heaven" (4:31), etc. In both cases, the king's decree praising the Most High includes a first-person account of his affliction.
There are several other verbal links between the Prayer of Nabonidus and Daniel 4-5:
(9) In the Prayer of Nabonidus, the affliction is "by the decree (b-ptgm) of God", and in Daniel 4:17 MT the affliction of Nebuchadnezzar is "the decree (ptgm') of the watchers".
(10) In the Prayer, the unnamed Jew is characterized as a "diviner" (gzr), and this term occurs in Daniel 4:7 to refer to the gzry' "soothsayers" the king summons to interpret his dream.
(11) This diviner is described as "a Jew fr[om among the exiles]" which may parallel the wording in Daniel 5:13 ("Daniel from among the exiles of Judah"). Not enough of the text however is preserved to be sure.
(12) Nabonidus in the Prayer says that for seven years he "was praying before the gods (qdm 'lhy) of silver and gold", compare Daniel 6:11: "Daniel was praying and supplicating before his god (qdm 'lhh)".
(13) Most strikingly, Nabonidus in the Prayer worshipped "gods of silver and gold, [bronze, iron], wood, stone, clay" ('lhy ksp' w-dhb' [nchsh' przl'] 'h' 'bn' chsp'), a phrase that finds a very close parallel in Daniel 5:4: "gods of gold, silver, bronze, iron, wood, and stone" ('lhy dhb' w-ksp' nchsh' przl' 'h' w-'bn'). As for "clay", this word occurs in the dream vision of ch. 2 which similarly presented a series of metals of decreasing value.
The Prayer of Nabonidus thus shows that traditions about Nabonidus lived on among the Jews and these traditions bear close literary links to the Danielic story in ch. 4, but the Prayer is at the same time more primitive: it gives the correct name of the king, it correctly names the king's location at Teima (while the LXX only states "the desert" more vaguely, and the MT gives no location whatsoever), and it even lacks the name of the Jewish diviner that heals the king. Just as the identity of the king is shifted from the obscure Nabonidus to the infamous Nebuchadnezzar in the Danielic version, so is the identity of the anonymous diviner filled by the famous Daniel. The clearest trace of Nabonidus in the biblical version is found in ch. 5, which construes Belshazzar as the son of the king humbled in ch. 4. The historical Belshazzar was the son of Nabonidus.