# Exception during restore: EXCEPTION: undefined method \`\[\]' for nil:NilClass

**URL:** https://meta.discourse.org/t/exception-during-restore-exception-undefined-method-for-nil-nilclass/34019
**Category:** Support
**Created:** [October 1, 2015, 10:47pm UTC](https://meta.discourse.org/t/exception-during-restore-exception-undefined-method-for-nil-nilclass/34019 "2015-10-01T22:47:18Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![ckamps](https://avatars.discourse-cdn.com/v4/letter/c/e95f7d/32.png) [@ckamps](https://meta.discourse.org/u/ckamps)
#### Post date: [October 1, 2015, 10:47pm UTC](https://meta.discourse.org/t/exception-during-restore-exception-undefined-method-for-nil-nilclass/34019/1 "2015-10-01T22:47:18Z")

</div>

Although I saw a topic with the same symptom, the resulting posts didn’t appear to align with our circumstances. When restoring a backup tar.gz from one Discourse instance to another, we received this error:

 ![](https://global.discourse-cdn.com/meta/original/3X/8/f/8f931396bb9a4c82d2006e880a1e263149e93959.png)

As part of troubleshooting, I entered the container and executed the following command to verify that what the `restorer` is doing to extract the `meta.json` file is working.

```
# tar --extract --file ./shared/backups/default/discussion-forums-pilot-meta-2015-10-01-215138.tar.gz meta.json

```

The file appears to be extracted cleanly:

# cat meta.json

{“source”:“discourse”,“version”:20150924022040}

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [October 1, 2015, 11:17pm UTC](https://meta.discourse.org/t/exception-during-restore-exception-undefined-method-for-nil-nilclass/34019/2 "2015-10-01T23:17:20Z")

</div>

How did you upload the backup file? I’ve seen that error happen when there was a permission issue due to manual upload to the server.

---

<div class="post-metadata">

### Author: ![ckamps](https://avatars.discourse-cdn.com/v4/letter/c/e95f7d/32.png) [@ckamps](https://meta.discourse.org/u/ckamps)
#### Post date: [October 2, 2015, 12:21am UTC](https://meta.discourse.org/t/exception-during-restore-exception-undefined-method-for-nil-nilclass/34019/3 "2015-10-02T00:21:20Z")

</div>

Via the web UI using Chrome

---

<div class="post-metadata">

### Author: ![ckamps](https://avatars.discourse-cdn.com/v4/letter/c/e95f7d/32.png) [@ckamps](https://meta.discourse.org/u/ckamps)
#### Post date: [October 2, 2015, 11:54am UTC](https://meta.discourse.org/t/exception-during-restore-exception-undefined-method-for-nil-nilclass/34019/4 "2015-10-02T11:54:46Z")

</div>

Tried to muddle through further troubleshooting by executing the restore from the CLI, but failed in two attempt:

First, I encountered `thor` as a missing dependency. After performing a `gem install thor` as root, I attempted the restore again, but then it failed with:

```
/var/www/discourse$ script/discourse restore discussion-forums-pilot-meta-2015-10-02-113808

Starting restore: discussion-forums-pilot-meta-2015-10-02-113808
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/postgresql_adapter.rb:665:in `rescue in connect': FATAL: database "discourse_development" does not exist (ActiveRecord::NoDatabaseError)
from /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/postgresql_adapter.rb:655:in `connect'
from /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/postgresql_adapter.rb:242:in `initialize'
from /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `new'
from /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `postgresql_connection'

```

---

<div class="post-metadata">

### Author: ![ckamps](https://avatars.discourse-cdn.com/v4/letter/c/e95f7d/32.png) [@ckamps](https://meta.discourse.org/u/ckamps)
#### Post date: [October 2, 2015, 6:51pm UTC](https://meta.discourse.org/t/exception-during-restore-exception-undefined-method-for-nil-nilclass/34019/5 "2015-10-02T18:51:42Z")

</div>

Turns out that contrary to the name of the downloaded file being `tar.gz`, it was actually in `tar` format. Consequently, upon upload and attempting to restore, the restore process failed. Entered the container, made the `tar.gz` a real `tar.gz` and the restore process proceeded.

---

<div class="post-metadata">

### Author: ![ckamps](https://avatars.discourse-cdn.com/v4/letter/c/e95f7d/32.png) [@ckamps](https://meta.discourse.org/u/ckamps)
#### Post date: [October 2, 2015, 7:02pm UTC](https://meta.discourse.org/t/exception-during-restore-exception-undefined-method-for-nil-nilclass/34019/6 "2015-10-02T19:02:35Z")

</div>

Restore worked, but I ran into the following issue that was worked around by hitting reload.

[https://meta.discourse.org/t/restore-failed-at-validating-metadata/31318/2](https://meta.discourse.org/t/restore-failed-at-validating-metadata/31318/2)

This issue can be closed.

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [October 2, 2015, 7:07pm UTC](https://meta.discourse.org/t/exception-during-restore-exception-undefined-method-for-nil-nilclass/34019/7 "2015-10-02T19:07:46Z")

</div>


