# Backup restoration fails

**URL:** https://meta.discourse.org/t/backup-restoration-fails/405387
**Category:** Self-hosting
**Tags:** backups
**Created:** [June 16, 2026, 8:15am UTC](https://meta.discourse.org/t/backup-restoration-fails/405387 "2026-06-16T08:15:13Z")
**Posts on this page:** 1
**Showing post:** 15

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [June 16, 2026, 12:13pm UTC](https://meta.discourse.org/t/backup-restoration-fails/405387/15 "2026-06-16T12:13:29Z")

</div>

It sounds like your old server isn’t a [standard install](https://meta.discourse.org/t/142537?silent=true). Anyway,… what happened in short: an index on your old server got broken over the years (this can happen after OS upgrades), so two identical rows slipped into the `incoming_referers` table. The backup copies them as-is, and the new server then refuses them. So we fix it on the **old** server first, then make a new backup.

**On the OLD server** , open the Rails console:

```plaintext
./launcher enter app
rails c

```

Then paste these lines, one after the other:

```ruby
db = ActiveRecord::Base.connection.current_database
DB.exec("DELETE FROM incoming_referers a USING incoming_referers b WHERE a.id > b.id AND a.path = b.path AND a.incoming_domain_id = b.incoming_domain_id")
DB.exec("REINDEX DATABASE #{ActiveRecord::Base.connection.quote_table_name(db)}")

```

This removes the duplicate and rebuilds all indexes (in case other tables are affected too).

If `REINDEX` finishes without an error, type `exit`, make a **fresh backup on the old server** , and restore that new file. If it shows an error about another table, just paste it here.

---

_[View the full topic](https://meta.discourse.org/t/backup-restoration-fails/405387)._
