# Getting this error during restore: \`could not create unique index\`

**URL:** https://meta.discourse.org/t/getting-this-error-during-restore-could-not-create-unique-index/138622
**Category:** Self-hosting
**Created:** [January 14, 2020, 11:36pm UTC](https://meta.discourse.org/t/getting-this-error-during-restore-could-not-create-unique-index/138622 "2020-01-14T23:36:16Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![IdentityDan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/identitydan/32/166537_2.png) [@IdentityDan](https://meta.discourse.org/u/IdentityDan)
#### Post date: [January 14, 2020, 11:36pm UTC](https://meta.discourse.org/t/getting-this-error-during-restore-could-not-create-unique-index/138622/1 "2020-01-14T23:36:16Z")

</div>

Howdy,

I am trying to get my staging instance up to date with my production instance. I successfully upgraded to the current version, but am receiving the following error while trying to restore my prod backup to my staging instance:

```plaintext
[2020-01-14 23:27:08] ERROR: could not create unique index "index_tags_on_lower_name"
[2020-01-14 23:27:08] DETAIL: Key (lower(name::text))=(net) is duplicated.
[2020-01-14 23:27:08] EXCEPTION: psql failed: DETAIL: Key (lower(name::text))=(net) is duplicated.

```

I found this topic which seems similar, but don’t know how to implement the solution.

> [@Add Tags 500 Error](https://meta.discourse.org/t/add-tags-500-error/129085):
>
> Hi, I just add Tags, 500 Error. logs: ActiveRecord::RecordNotUnique (PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "index\_tags\_on\_name" DETAIL: Key (name)=(TAGTEST) already exists. ) /var/www/discourse/vendor/bu Failed to handle exception in exception app middleware : PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "index\_tags\_on\_name" DETAIL: Key (name)=(TAGTEST) already exists. Discourse 2.4.0.beta4

Any guidance would be appreciated!

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [January 15, 2020, 5:07pm UTC](https://meta.discourse.org/t/getting-this-error-during-restore-could-not-create-unique-index/138622/2 "2020-01-15T17:07:02Z")

</div>

I had a similar issue. I describe how I fixed it in [Can't restore due to corrupt indexes (with some clues on how to deal with corrupt indexes) - #3 by pfaffman](https://meta.discourse.org/t/cant-restore-due-to-corrupt-indexes-with-some-clues-on-how-to-deal-with-corrupt-indexes/137400/3), but it’s largely hand-waiving.

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [November 20, 2023, 2:34am UTC](https://meta.discourse.org/t/getting-this-error-during-restore-could-not-create-unique-index/138622/3 "2023-11-20T02:34:02Z")

</div>



---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [November 20, 2023, 6:53am UTC](https://meta.discourse.org/t/getting-this-error-during-restore-could-not-create-unique-index/138622/4 "2023-11-20T06:53:02Z")

</div>


