@
smei 
for recognising this was caused by something you did, you'd be amazed how many folks swear black-'n'-blue they didn't do nuffin', and insist that calibre ate their library.
I'll assume the path to your broken library is
/Users/thebestdog/Documents/Calibre Library/
Try this -
- start calibre with that broken library,
- create an empty library see first attachment
- close calibre
- open the broken library folder in Finder
- delete the metadata.db file and and any other FILES, leave the folders as they are
- using Finder copy the metadata.db from that empty library folder (/Users/thebestdog/Documents/_NewLibrary) into the the broken library folder (/Users/thebestdog/Documents/Calibre Library/)
- start calibre (and go into the broken library) - it will be empty
- run the Library Maintenance->Library Restore function - now you should have a lot of your library back
- run the Library Maintenance->Check Library - clear up all anomalies.
- hit the button that copies the 'report' into the clipboard, and paste that into a text editor, so you can see it
- close calibre
- then use the list to carefully move dodgy author and book folders and any dodgy files out of the library folder to a scratch area
- start calibre and rerun the Check Library - hopefully it will now be error free.
- now you can deal what you copied to the scratch area by adding anything that's worthwhile to your library
- you can trash that _NewLibrary from calibre's view via Library->Remove library and then deleting the folder in Finder.
If that doesn't fix it then hmmm - what happened?
I do not have a MAC, but if I did then I probably would not run calibre and Time Machine concurrently. I would try to achieve that via an Automaton that suspended Time Machine's monitoring of my ebook library folders before it starting calibre and resuming Time Machine's monitoring of them when calibre terminated. I have no idea if that's actually possible.
BR