fix for database duplicates in restore loop