The discussion addresses an undefined method [] for nil error encountered during a Discourse backup restore. ckamps reported the issue while attempting to restore a backup file named discussion-forums-pilot-meta-2015-10-01-215138.tar.gz. After verifying the file extraction and confirming the upload was done via the web UI, ckamps noted that manual CLI attempts initially failed due to missing dependencies and database connection errors ckamps. zogstrip suggested checking for permission issues related to manual uploads, but the root cause was ultimately identified by ckamps. The file, despite its .tar.gz extension, was actually in uncompressed tar format. Once ckamps re-compressed the file correctly into a valid tar.gz, the restore process succeeded. A subsequent issue regarding metadata validation was resolved by performing a reload, referencing a related thread restore-failed-at-validating-metadata. The original poster confirmed the matter is resolved and can be closed.
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
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.