An alternative is to use the
calibredb command with the restore-database option to rebuild the database from the calibre library folders and files.
This does require you to have previously been running a recent enough version of Calibre for the book folders to contain a metadata.opf file to get all metadata recovered, but the generation of that file has been a feature of Calibre for some time now.