Error restoring backup "key is duplicated"

I’ve seen a few similar reports like Error (could not create unique index "badges_pkey") attempting to restore backup. I suspect that there is a bug somewhere, but no one has shown a way to replicate it.

I think your solution is to do this: Advanced, manual method of manually creating and restoring Discourse backups.