You can reset Calibre Library back to a known good situation, as described here:
https://github.com/eli-schwartz/dropbox-restore
Personally I favor using Library Maintenance and tracking down the messed up book records, since otherwise edits are lost. Chances are you just need to delete the listed folders, but it is possible (?) there will be missing formats listed as well, in which case you will need to put them back in the right place.
But I did use the linked tool one time when I accidentally synced a second computer and ended up with a billion edit clashes. All I wanted to do there was roll the changes back anyway.