"Dangerous" is relative. In most cases, you won't sustain much harm by doing so, although the items in your backpack might get crushed. I have had it explained to me before by my former teachers (jujitsu and Bujinkan) that this is one of the reasons some of the defenses involve turning a flip to escape from a hold rather than a roll, because it prevents you from rolling over your sword. At that, a breakfall may also be a better choice in some situations. Learning multiple options lets you react appropriately for the situation.
I suppose it might depend on the content of your backpack too. Breakables, sharps, and objects with lumpy corners could dig into your spine or organs close to the surface. shrug It's probably about the same risk that you'd face if the contents of your backpack were on the ground and you rolled over them.