# Restoring from backup failing: failure creating postgres index

**URL:** <https://meta.discourse.org/t/restoring-from-backup-failing-failure-creating-postgres-index/153014>\
**Category:** Self-hosting\
**Created:** [27 במאי,‏ 2020,‏ 7:59pm UTC](https://meta.discourse.org/t/restoring-from-backup-failing-failure-creating-postgres-index/153014 "2020-05-27T19:59:18Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![Dustin\_Lang](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dustin_lang/32/182052_2.png) [@Dustin\_Lang](https://meta.discourse.org/u/Dustin_Lang)\
**Post date:** [27 במאי,‏ 2020,‏ 7:59pm UTC](https://meta.discourse.org/t/restoring-from-backup-failing-failure-creating-postgres-index/153014/1 "2020-05-27T19:59:18Z")

</div>

Hi all,

I’ve been running Discourse painlessly for several years.

Today, I tried doing a web ui upgrade from the 2.4.0beta-something version I was running to the current (2.5.0beta5). This… did not go well. I did not take good notes, but it seemed like postgres was not starting up correctly due to the postgres data directory not being owned by the correct user.

I thought I would try cloning my old containers/app.yml to app2 and restoring from a backup. The new container built and I followed instructions for running a command-line backup ([Restore a backup from the command line - #12](https://meta.discourse.org/t/restore-a-backup-from-command-line/108034/12)). “discourse restore ” fails with

```plaintext
ERROR: could not create unique index "index_incoming_referers_on_path_and_incoming_domain_id"
DETAIL: Key (path, incoming_domain_id)=(//viewer/, 16) is duplicated.
EXCEPTION: psql failed: DETAIL: Key (path, incoming_domain_id)=(//viewer/, 16) is duplicated.
/var/www/discourse/lib/backup_restore/database_restorer.rb:95:in `restore_dump'
/var/www/discourse/lib/backup_restore/database_restorer.rb:26:in `restore'
/var/www/discourse/lib/backup_restore/restorer.rb:49:in `run'
script/discourse:143:in `restore'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/thor-1.0.1/lib/thor/command.rb:27:in `run'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/thor-1.0.1/lib/thor/invocation.rb:127:in `invoke_command'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/thor-1.0.1/lib/thor.rb:392:in `dispatch'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/thor-1.0.1/lib/thor/base.rb:485:in `start'
script/discourse:284:in `<top (required)>'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `load'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `kernel_load'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:28:in `run'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli.rb:476:in `exec'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor.rb:399:in `dispatch'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli.rb:30:in `dispatch'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/base.rb:476:in `start'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli.rb:24:in `start'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/exe/bundle:46:in `block in <top (required)>'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/friendly_errors.rb:123:in `with_friendly_errors'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/exe/bundle:34:in `<top (required)>'
/usr/local/bin/bundle:23:in `load'
/usr/local/bin/bundle:23:in `<main>'
Trying to rollback...
Rolling back...
Cleaning stuff up...

```

Any suggestions on how to proceed would be very welcome.

Thanks!  
–dustin

---

_[View the full topic](https://meta.discourse.org/t/restoring-from-backup-failing-failure-creating-postgres-index/153014)._
