Legally, you paid for the albums (im assuming), so ripping them as back ups and storing them is perfectly fine. In the stupidly low off chance some authorities decided to ask questions, all you need are the physical copies of said CDs to match the tracks stored. All this is based on you having legit store bought CDs.
I'll use a scenario. I have a copy of Meteora by Linkin Park in my CD folder. I rip it and store it to OneDrive. Cops or higher get suspicious and question me. I pull out the CD and because I proved I bought the tracks in question, they can't arrest or seize my computer/account. This applies to higher quality MP3s as well. If you decide you want better sounding tracks from the CD you want (320 vs the 198 you get from ripping), you're still protected so long as you can prove you already bought the tracks once. This applies to software as well.
Sharing it to others who haven't paid for those tracks, or don't own the paid for CD software, is where it becomes illegal. Hope this helps!