How to backup Docker discourse from command-line before rebuilding broken Discourse?

Yes there is. SSH to your server, and run the following:

cd /var/discourse
./launcher enter app
discourse backup

Running ./discourse-setup or ./launcher rebuild app are both safe, neither will throw your data away, they solely modify the application.