Is it possible, after tuning Discourse on local computer, to export all settings into file and upload them into production?
Thanks.
Is it possible, after tuning Discourse on local computer, to export all settings into file and upload them into production?
Thanks.
I guess probably you can export your settings from DB.
discourse=>\dt
...
...
public | single_sign_on_records | table | discourse
public | site_customizations | table | discourse
public | site_settings | table | discourse
public | stylesheet_cache | table | discourse
...
...
Notice site_settings table. You can also take this data from your backup. It already have a dump of your database inside it.
Then all you need to do is restore this table to your server from your local dump.
Courtesy of @blake we now have rake tasks to export/import site settings:
rake site_settings:export > settings.yml
rake site_settings:import < settings.yml
For those who do not have access to rake
tasks, I also have contributed a settings uploader that uses the API: https://github.com/pfaffman/discourse-settings-uploader
Hello,
I’ve used discourse-settings-uploader to upload site_settings.json file from the GitHub Jay mentioned. I get this error when I run it:
./discourse-settings-uploader:39:in `<main>': undefined method `each' for nil:NilClass (NoMethodError)
line39: settings['site_settings'].each do |setting|
line40: jsetting (setting) unless setting['value'] == setting['default']
line41: end
I used an API key for “All Users” and used “system” when I ran discourse-settings-uploader.
Any thoughts?
For future reference some problems I had using discourse-settings-uploader
, getting 301 errors:
./discourse-settings-uploader community.mysite.com 22f7d44321ae2365d3e3a5e9224524ba0e7302bd75ed06bfbh31ed5090ec6d3b system site-settings.json
SiteSettingtitle="Mysite"
E! 301 Moved Permanently
I get this error once for each setting. But I can browse the site successfully at those URLs. So I figured out - it’s going through http
, and that is disabled.
So now I add https
to my site name and I get a different error:
SiteSettingtitle="My sIte"
E! SSL_connect returned=1 errno=0 state=error: certificate verify failed (unable to get local issuer certificate)
something's wrong with https://community.mysite.com/admin/site_settings/title {"title"=>"Mysite", :api_key=>"22f7d44321ae2365d3e3a5e9224524ba0e7302bd75ed06bfbh31ed5090ec6d3b ec6d3b", :api_username=>"system"}
So this boils down to a deficient local configuration of root certificates, it seems. I could go off and waste an afternoon on this, but instead what I did was turn off verify_ssl
. It’s very insecure and horrible things will happen to you and your children and your children’s children but for this case, I just didn’t care.
So in the uploader script I added this method:
def put_no_ssl(url, payload, headers={}, &block)
RestClient::Request.execute(method: :put, url: url, :payload => payload, headers: headers, verify_ssl: false, &block)
end
And below, I changed the call from
r = RestClient.put(url, my_hash)
to
r = put_no_ssl(url, my_hash)
And it worked!
Hello community,
I need to export the site settings from the production to the staging. I found this instruction Discourse-Settings Uploader, created a json file with settings but do not have a possibility to import it. I do not know where I can run this command
./discourse-settings-uploader HOSTURL API_KEY API_USER SETTINGS_FILE
Should it be done via terminal? My client told me that they use a community discourse and do not have terminal access. What does it mean? How is it better to solve my issue? I am pretty new to this, so I need your help.
Thank you in advance.
Have a look at Backup only Site Settings. You need to download the script from github and have Ruby installed.
rake site_settings:import < settings.yml
just wanted to mention the docker version of this command:
d/rake "site_settings:import < settings.yml"
in case you get
The input device is not a TTY
Hey @pfaffman
I tried exactly as given… ./discourse-settings-uploader https://discourse.example.com d35989078a system site_settings.json
But my script fails and I am not sure why and how.
It gives E! 404 Not Found
for every setting
I removed your screenshot as it includes your API key. Feel free to add another screenshot that doesn’t have (or obscures) the sensitive data. You should also rotate the key given it was public it should be treated as compromised.
Thanks for the immediate followup. I will take care of such practices from now on.
If you’re getting a 404 then your api key is wrong or it’s not where the script can find it.
I have checked this. And all my APIs are working the same Key.
and I am sure the script might be looking in right place as the log statement has urls like
{url}/admin/site_settings/title
{url}/admin/site_settings/site_description
I have downloaded site_settings.json from one site and now trying to push the settings into a existing site2. Should I do any edits to the site_settings.json that I downloaded ?
Strange. Sorry, but that’s my best free answer. You can message me if you have a budget.
There’s a rake task you can try if you are self hosted on both sites.
I don’t use that script myself these days. It could be that something in discourse changed, but I doubt it. If you’re sure you’re using the API key for the site that you’re trying to write to then I don’t have a guess.
I tried using rake site_settings:export > settings.yml
. I noticed that the tags and tags groups that I configured on my Discourse server are not exported. Why is that?
Tags are tags, not site settings. I’m not aware of a way to migrate tags.
Is there a way to also export the settings for plugins theme components?