Forum rendered unusable

Hi, I’m trying to enable S3 backups to a Min.IO server. When I change app.yml to what I think reflects the documentation, then rebuild, on completion all I get in the browser is the 4 coloured dots in the middle of the screen. When I look in the console I get;

Uncaught ReferenceError: I18n is not defined
    at admin?v=103a67b2358b…86c5a58d96d4e91:1:1
wizard?v=ab2295f1774…85b733472935c34a0:1 
Uncaught ReferenceError: I18n is not defined
    at wizard?v=ab2295f1774…b733472935c34a0:1:1

My changes to app.yml are as follows;

  DISCOURSE_BACKUP_LOCATION: 's3'
  DISCOURSE_USE_S3: 'true'
  DISCOURSE_S3_REGION: 'off-cloud-backup'
  DISCOURSE_S3_ENDPOINT: 'http://borg....'
  DISCOURSE_S3_ACCESS_KEY_ID: '(my uid here)'
  DISCOURSE_S3_SECRET_ACCESS_KEY: '(my key here)'
  DISCOURSE_S3_CDN_URL: 'http://borg....'
  DISCOURSE_S3_BUCKET: 'assets'
  DISCOURSE_S3_BACKUP_BUCKET: 'discourse-data'
  DISCOURSE_S3_INSTALL_CORS_RULE: 'false'

On the Min server I have the region set up, then a public bucket called ‘assets’, then a private bucket called ‘discourse-data’, and obviously credentials to match. I’ve tried without quotes around the variables just in case because some of the examples do this - no change.

If I change these and restart, they don’t seem to take. I need to do a rebuild for them to activate which makes the testing cycle pretty painful. Would be a little easier if these fields were all available in the admin settings, which they seem to have been historically, or at least they appear on some people’s screen grabs (?)

If I comment out all the _S3 entries in app.yml and rebuild, it works fine. (I just don’t have backups configured) (the ENDPOINT and CDN url’s do resolve locally to the right IP)

Getting everything else set up, including subscriptions, was all relatively easy, but I’ve hit a brick wall with this. Anyone any idea what I’m doing wrong?

Do you want just backups on S3? I if so. You need only to have the keys and the backup bucket.

You’ve got it configured for all assets in S3, but you likely left out the part at the top of the instructions that have rake tasks to precompile assets and push them to S3.

Hi, thanks for that, I’m about to try two things then;

  • Rebuild with ACCESS, SECRET and BACKUP_BUCKET (and I’m assuming endpoint?)
  • Trying to add the rake tasks and rebuild

You’re right in that I only wanted the data initially, but probably would have progresses to assets once something was working.

That all said, my (very poor) interpretation of the documentation rendering the site as effectively dead, seems potentially problematic for newbies. I’m not sure why the console is reporting I18n as an issue, but it looks like a minor mod in the code something like;

if (I18n && I18n.xxx) 

rather than;

if (I18n.xxx)

Might protect newbies from killing their sites … should I trawl and try to make a PR, or is this something someone with more expertise might look at? Happy to have a go, but don’t want to waste my time if it’s not useful … ?

Mmm, Ok, made a little progress, the stripped down settings now allow the page to render, however I’m now getting a ‘bad request’ back from the server. I’m testing the S3 storage from the discourse machine using Min.io’s “mc” tool and it seems to work fine and I can list buckets … however in the logs I’m getting;

Failed to list backups from S3: Aws::S3::Errors::BadRequest

And

/var/www/discourse/lib/backup_restore/s3_backup_store.rb:140:in `rescue in unsorted_files' 
/var/www/discourse/lib/backup_restore/s3_backup_store.rb:131:in `unsorted_files' 
/var/www/discourse/lib/backup_restore/backup_store.rb:23:in `files' 

I made a point to copy/paste the settings from app.yml into the “mc” config to make sure there were no typo’s … so I’m at a bit of a lostt for a second. Might have another go tomorrow …

It’s trying to list the contents of the bucket.

You do not need the rake task that has to do with assets.

It’s trying to list the contents of the bucket.
You do not need the rake task that has to do with assets.

Ok, thanks for your help, I did spot that, however it’s not really helping. I’ve tried Min.io and I’ve tried SeaweedFS, both I’ve configured up locally to the point where I’ve been able to write a file to S3 using a command line tool from the Discourse machine, neither option seems to want to play ball from within Discourse. After reviewing time-spent, I guess if backups are online and S3 I can see how the option to backup directly to S3 is great, however if your backups are “off cloud”, and you need to emulate S3 storage just to use the option, for me it’s become a little too expensive in terms of time.

Incidentally, I notice someone saying that CloudFlare S3 now works, which might be good for some people. CloudFlare seem to have added 10G of S3 to their free tier, however for me my backups are typically off-cloud on a Borg backup server.

What I’ve done instead is to add the discourse host machine to my backup VPN, installed borg and borgmatic covering /var/discourse/shared/standalone/backups and /var/discourse/shared/standalone/log on the host, then added this to cron 30 mins after the local backup is schedules.

Q: Cloud you clarify whether the local backups cover everything, or do I need more to cover uploads? (are the additional rake tasks just for S3?)

My paranoid self just doesn’t trust cloud providers with both live systems AND backups. Every time I think that maybe I worry too much, I remind myself of the time I turned up to a customer site in response to my server isn’t working to find that it had been struck by lightening - inside the server room.

Did you follow the minio-specific instructions here? Configure an S3 compatible object storage provider for uploads

If you’re just changing those ENV variables then you can do a

  ./launcher destroy app;./launcher start app

If you’re going to put assets there and not just backups, then don’t miss the rake task that pushes assets there.

1 Like

Did you follow the minio-specific instructions here?

Yes I did. I’m quite happy to admit I may have made mistakes and not read / retained everything, but googling for appropriate docs wasn’t one of them … :wink:

./launcher destroy app;./launcher start app

Ok, that’s useful for future reference, I was trying stop / start, not all that familiar with how docker builds env vars on boot.

If you’re going to put assets there and not just backups, then don’t miss the rake task that pushes assets there.

Sure, that was the bit that I was a little confused about, I’ll add them. Was just wondering why these wouldn’t be part of the default backup, I know there is a space issue, but my expectation would be that in general people want a backup of all of their content? (and as most people don’t seem to verify their contents, err’ing on the side of everything maybe safer?)

Hmm, I tried it on my test instance first (!) … I cut and pasted two lines fron the docs … is something out of date somewhere?

I, [2023-09-04T18:39:51.544973 #1]  INFO -- : > cd /var/www/discourse/plugins && sudo -E -u discourse bundle exec rake s3:upload_assets
bundler: failed to load command: rake (/var/www/discourse/vendor/bundle/ruby/3.2.0/bin/rake)
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/definition.rb:524:in `materialize': Could not find css_parser-1.16.0, oj-3.16.1, rotp-6.3.0, globalid-1.2.0, google-protobuf-3.24.2-x86_64-linux in locally installed gems (Bundler::GemNotFound)
        from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/definition.rb:197:in `specs'
        from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/definition.rb:254:in `specs_for'
        from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/runtime.rb:18:in `setup'
        from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler.rb:162:in `setup'
        from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/setup.rb:23:in `block in <top (required)>'
        from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/ui/shell.rb:159:in `with_level'
        from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/ui/shell.rb:111:in `silence'
        from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/setup.rb:23:in `<top (required)>'
        from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/cli/exec.rb:56:in `require_relative'
        from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/cli/exec.rb:56:in `kernel_load'
        from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/cli/exec.rb:23:in `run'
        from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/cli.rb:492:in `exec'
        from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
        from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
        from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
        from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/cli.rb:34:in `dispatch'
        from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
        from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/cli.rb:28:in `start'
        from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/exe/bundle:45:in `block in <top (required)>'
        from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
        from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/exe/bundle:33:in `<top (required)>'
        from /usr/local/bin/bundle:25:in `load'
        from /usr/local/bin/bundle:25:in `<main>'
I, [2023-09-04T18:39:52.163459 #1]  INFO -- : 
I, [2023-09-04T18:39:52.164462 #1]  INFO -- : Terminating async processes

My hooks looks like this;

hooks:
  after_code:
    - exec:
        cd: $home/plugins
        cmd:
          - sudo -E -u discourse bundle exec rake s3:upload_assets
          - sudo -E -u discourse bundle exec rake s3:expire_missing_assets
          - sudo -E -u discourse git clone https://github.com/discourse/docker_manager.git
          - sudo -E -u discourse git clone https://github.com/discourse/discourse-whos-online
          - sudo -E -u discourse git clone https://github.com/discourse/discourse-solved.git
          - sudo -E -u discourse git clone https://github.com/discourse/discourse-reactions.git
          - sudo -E -u discourse git clone https://github.com/discourse/discourse-subscriptions.git
          - sudo -E -u discourse git clone https://github.com/discourse/discourse-topic-voting.git
          - sudo -E -u discourse git clone https://github.com/discourse/discourse-calendar.git
          - sudo -E -u discourse git clone https://github.com/sylque/discourse-home-page.git
          - sudo -E -u discourse git clone https://github.com/sylque/discpage.git
          - sudo -E -u discourse git clone https://github.com/discourse/discourse-onboarding-banner.git

Those rake tasks don’t go there.

If your uploads are are on S3 then you’re counting on the S3 manager to make it work so you don’t need backups. There’s a hidden settign to download assets from S3 and include them in the backup, but you almost certainliy don’t want to do that.

Mmm, I’d noted previously that someone else had talked about putting stuff in the wrong section, then I went ahead and did the same thing anyway, eek (!)

So after reading more carefully, I still seem to have an issue, I have;

hooks:
  after_code:
    - exec:
        cd: $home/plugins
        cmd:
          - git clone https://github.com/discourse/docker_manager.git
          - git clone https://github.com/discourse/discourse-whos-online
          - git clone https://github.com/discourse/discourse-solved.git
          - git clone https://github.com/discourse/discourse-reactions.git
          - git clone https://github.com/discourse/discourse-subscriptions.git
          - git clone https://github.com/discourse/discourse-topic-voting.git
          - git clone https://github.com/discourse/discourse-calendar.git
          - git clone https://github.com/sylque/discourse-home-page.git
          - git clone https://github.com/sylque/discpage.git
          - git clone https://github.com/discourse/discourse-onboarding-banner.git

  after_assets_precompile:
    - exec:
        cd: $home
        cmd:
          - sudo -E -u discourse bundle exec rake s3:upload_assets
          - sudo -E -u discourse bundle exec rake s3:expire_missing_assets

It says paste into app.yml in the hooks section … does this look right or am I still in the wrong place? The error I’m getting now is;

FAILED
--------------------
Pups::ExecError: cd /var/www/discourse && sudo -E -u discourse bundle exec rake s3:upload_assets failed with return #<Process::Status: pid 1845 exit 1>
Location of failure: /usr/local/lib/ruby/gems/3.2.0/gems/pups-1.1.1/lib/pups/exec_command.rb:117:in `spawn'
exec failed with the params {"cd"=>"$home", "cmd"=>["sudo -E -u discourse bundle exec rake s3:upload_assets", "sudo -E -u discourse bundle exec rake s3:expire_missing_assets"]}
bootstrap failed with exit code 1

I’m looking back through the logs for more details but I’m not seeing anything. Unfortunately I’ve never coded in Ruby so I don’t really know what I’m looking at / for, any ideas?

Note; it advised running ./discourse-doctor, which I did, bit it didn’t seem to tell me anything different …