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

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:

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}

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.

Via the web UI using Chrome

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'

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.

1 Like

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

This issue can be closed.