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

(Christopher Kampmeier) #1

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


(Régis Hanol) #2

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.

(Christopher Kampmeier) #3

Via the web UI using Chrome

(Christopher Kampmeier) #4

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'

(Christopher Kampmeier) #5

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.

(Christopher Kampmeier) #6

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

This issue can be closed.

(Kane York) #7