I am trying to migrate all data from S3 back to my server. But, rake uploads:migrate_from_s3 returns error You must disable S3 uploads before running that task. So I unchecked enable s3 uploads option in my discourse setting and also added DISCOURSE_USE_S3: false to my app.yml file. But still no luck, the same error.
What is an S3 env variable? In my case, DISCOURSE_USE_S3 is kept under env.
env:
LANG: en_US.UTF-8
# DISCOURSE_DEFAULT_LOCALE: en
UNICORN_WORKERS: 2
## TODO: The domain name this Discourse instance will respond to
DISCOURSE_HOSTNAME: engineersasylum.com
## Uncomment if you want the container to be started with the same
## hostname (-h option) as specified above (default "$hostname-$config")
#DOCKER_USE_HOSTNAME: true
## TODO: List of comma delimited emails that will be made admin and developer
## on initial signup example 'user1@example.com,user2@example.com'
DISCOURSE_DEVELOPER_EMAILS: 'praveen369gen@gmail.com'
#S3 Configuration
DISCOURSE_USE_S3: false
DISCOURSE_S3_REGION: ap-south-1
DISCOURSE_S3_ACCESS_KEY_ID: AKxxxxxxxxxxxxxxxxxxxxxDQ
DISCOURSE_S3_SECRET_ACCESS_KEY: QWVxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxLigGs
DISCOURSE_S3_BUCKET: enginxxxxxxxxxxket
DISCOURSE_S3_BACKUP_BUCKET: enginxxxxxxxxxxxxcket
DISCOURSE_BACKUP_LOCATION: s3
… and don’t forgot @Pravi that you must rebuild your container (app) after you change most of the vars in your yml file; some might change by stopping and starting your container; but when it doubt, rebuild the container (app) after you make a change to your yml.
I added local to backup location, then rebuild the container and tried to migrate, but still no luck. Its giving me You must disable S3 uploads before running that task
After you rebuild with the DISCOURSE_USE_S3=false in the yml, you ran the rake task and it still says “You must disable S3 uploads”? Did you go to your admin panel and disable S3 there also?
Yes, I add DISCOURSE_USE_S3=false to the app.yml, then I rebuild the container, then rake task but still, it’s giving me same output. Yes, I disabled upload in the admin page.
I don’t know how the last one can be true if you set the env variable to false and rebuild. The SiteSetting ones are from your admin panel and the GlobalSettings is through the app.yml.
Unsetting DISCOURSE_USE_S3 and DISCOURSE_S3_BUCKET gives me this error,
root@ip-172-31-7-247-app:/var/www/discourse# rake uploads:migrate_from_s3
Migrating uploads from S3 to local storage for 'default'...
rake aborted!
NoMethodError: undefined method `downcase' for nil:NilClass
/var/www/discourse/app/models/global_setting.rb:107:in `s3_bucket_name'
/var/www/discourse/app/models/site_setting.rb:157:in `absolute_base_url'
/var/www/discourse/lib/tasks/uploads.rake:138:in `migrate_from_s3'
/var/www/discourse/lib/tasks/uploads.rake:118:in `block in migrate_all_from_s3'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rails_multisite-2.3.0/lib/rails_multisite/connection_management.rb:68:in `with_connection'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rails_multisite-2.3.0/lib/rails_multisite/connection_management.rb:78:in `each_connection'
/var/www/discourse/lib/tasks/uploads.rake:118:in `migrate_all_from_s3'
/var/www/discourse/lib/tasks/uploads.rake:93:in `block in <main>'
/usr/local/bin/bundle:23:in `load'
/usr/local/bin/bundle:23:in `<main>'
Tasks: TOP => uploads:migrate_from_s3
(See full trace by running task with --trace)
Update:
Before Unsetting DISCOURSE_USE_S3 and DISCOURSE_S3_BUCKET,
I tried that too. Commented out everything except DISCOURSE_USE_S3: false and the same error as previous pops up.
root@ip-172-31-7-247-app:/var/www/discourse# rake uploads:migrate_from_s3
Migrating uploads from S3 to local storage for 'default'...
rake aborted!
NoMethodError: undefined method `downcase' for nil:NilClass
/var/www/discourse/app/models/global_setting.rb:107:in `s3_bucket_name'
/var/www/discourse/app/models/site_setting.rb:157:in `absolute_base_url'
/var/www/discourse/lib/tasks/uploads.rake:138:in `migrate_from_s3'
/var/www/discourse/lib/tasks/uploads.rake:118:in `block in migrate_all_from_s3'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rails_multisite-2.3.0/lib/rails_multisite/connection_management.rb:68:in `with_connection'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rails_multisite-2.3.0/lib/rails_multisite/connection_management.rb:78:in `each_connection'
/var/www/discourse/lib/tasks/uploads.rake:118:in `migrate_all_from_s3'
/var/www/discourse/lib/tasks/uploads.rake:93:in `block in <main>'
/usr/local/bin/bundle:23:in `load'
/usr/local/bin/bundle:23:in `<main>'
Tasks: TOP => uploads:migrate_from_s3
(See full trace by running task with --trace)