Launcher run app gives error when trying backup

This gives me just errors, starting Redis.

/var/discourse/launcher run app "echo 'BackupRestore::Backuper.new(Discourse.system_user.id, with_uploads: false).run' | rails c"

If I take rails c route backuping works. But that oneliner should work too — or it is worked back 2020 (or was it -22…)

And what I really try to do is get just database dump, packed, in such place I can move it to S3. And no, I don’t want to do it manually, backuping must be automated. And no, once a day is not enough, because I don’t want miss worth of 24 hours stuff if something goes badly south.

Just cross-linking the reference (from 2020) in case it should be updated:

Do you mean connecting to redis? What is the actual error you see?

launcher run app runs a command in a new container context, so redis won’t be running. This would only work if redis is external.

The following should work as it runs in the context of the existing container:

docker exec -i app rails c <<<'BackupRestore::Backuper.new(Discourse.system_user.id, with_uploads: false).run'

Why are you doing the above over e.g. the simpler discourse backup --sql-only?

You can also tell Discourse to use S3 directly as a location for backups, if you want.

2 Likes

Because Docker and containers are horrible places, where nothing works, like crontab and nano :joy: I know, kind of, what I do when I see /var/discourse but after ./launcher enter app I am totally lost. That’s why my Mastodon-server backups itself, but Discourse not (well, once a day yes, but still).

Yes, I know discourse backup do what I want, it even sends the dump to S3, but I don`t how to time it — because that horrible and terryfying container thingy, that is an OS inside an OS.

You have a scheduler outside of the container available, right?

You can schedule it there, e.g.:

# put in host crontab
# run backup once every 4 hours on the hour
0 */4 * * * docker exec app discourse backup --sql-only
5 Likes

That was so easy that it was almost the biggest anti-climax of the day. And now I have one awscli totally without use.

docker exec is the key here… now I have one solid thing to start googling.

Thanks!

3 Likes

Oh yeah… that error:

Couldn't connect to Redis
bundler: failed to load command: pry (/var/www/discourse/vendor/bundle/ruby/3.3.0/bin/pry)
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/redis-4.8.1/lib/redis/client.rb:398:in `rescue in establish_connection': Error connecting to Redis on localhost:6379 (Errno::ECONNREFUSED) (Redis::CannotConnectError)

Amd after that was a mile long list where every line started from and there was zillion different ruby things, gems etc. It didn’t look very interesting.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.