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: GitHub - pfaffman/discourse-settings-uploader: Install a Discourse settings JSON file to a site · GitHub
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! ![]()
![]()
커뮤니티 여러분,
프로덕션 환경의 사이트 설정을 스테이징 환경으로 내보내야 합니다. Discourse-Settings Uploader라는 지침을 찾아 설정이 담긴 JSON 파일을 만들었지만, 이를 가져올 수 있는 방법이 없습니다. 이 명령어를 어디서 실행해야 하는지 모르겠습니다.
./discourse-settings-uploader HOSTURL API_KEY API_USER SETTINGS_FILE
터미널을 통해 실행해야 하는 건가요? 클라이언트는 커뮤니티 디스코urses를 사용하며 터미널 접근 권한이 없다고 말했습니다. 이것이 무슨 의미인가요? 이 문제를 해결하는 더 나은 방법은 무엇일까요? 저는 이 분야에 초보자인데 도움이 필요합니다.
미리 감사드립니다.
Backup only Site Settings - #5 by pfaffman 을 확인해 보세요. GitHub에서 스크립트를 다운로드하고 Ruby가 설치되어 있어야 합니다.
rake site_settings:import < settings.yml
이 명령어의 Docker 버전을 언급하고 싶었습니다:
d/rake "site_settings:import < settings.yml"
아래와 같은 오류가 발생하는 경우를 대비해서요.
The input device is not a TTY
안녕하세요 @pfaffman
제시된 대로 정확히 시도해 보았습니다… ./discourse-settings-uploader https://discourse.example.com d35989078a system site_settings.json
하지만 스크립트가 실패하는데, 그 이유와 방법을 모르겠습니다.
모든 설정에 대해 E! 404 Not Found 오류가 발생합니다.
API 키가 포함되어 있어 스크린샷을 삭제했습니다. 민감한 데이터가 없거나 가려진 다른 스크린샷을 추가해 주세요. 또한 해당 키가 공개되었으므로 유출된 것으로 간주하고 키를 교체해야 합니다.
즉시 후속 조치를 취해 주셔서 감사합니다. 앞으로는 이러한 관행을 철저히 준수하겠습니다.
404 오류가 발생했다면 API 키가 잘못되었거나, 스크립트가 해당 키를 찾을 수 없는 위치에 있는 것입니다.
확인해 보았습니다. 그리고 제 모든 API가 동일한 키를 사용하고 있습니다.
로그 문구에 {url}/admin/site_settings/title
{url}/admin/site_settings/site_description
과 같은 URL이 포함되어 있으므로, 스크립트가 올바른 위치를 참조하고 있다고 확신합니다.
한 사이트에서 site_settings.json 파일을 다운로드했고, 이제 기존 사이트2에 설정을 적용(push)하려고 합니다. 다운로드한 site_settings.json 파일에 대해 편집해야 할 부분이 있을까요?
이상하네요. 죄송하지만 이것이 제가 드릴 수 있는 무료 답변의 전부입니다. 예산이 있으시면 메시지를 보내 주세요.
두 사이트 모두 자체 호스팅을 사용하고 있다면 시도해 볼 수 있는 rake 태스크가 있습니다.
요즘은 제가 그 스크립트를 직접 사용하지 않습니다. discourse에서 무언가가 변경되었을 수도 있지만, 그럴 가능성은 낮다고 봅니다. 쓰려는 대상 사이트의 API 키를 사용하고 있다는 데 확신이 있다면, 제가 추측할 만한 것도 없습니다.
저는 rake site_settings:export > settings.yml을 사용해 보았습니다. 제 Discourse 서버에서 설정한 태그와 태그 그룹이 내보내지지 않는다는 것을 알게 되었습니다. 왜 그런 것일까요?
태그는 태그일 뿐이며 사이트 설정이 아닙니다. 태그를 이전하는 방법을 알고 있지 않습니다.
플러그인 테마 구성 요소의 설정도 내보내는 방법이 있나요?