What is rebaking and is it necessary when moving a server?

Can somebody point me to information about the rebake function?

Is this something that has to be done after moving a Discourse server to a new self hosted Linux server?

Rebaking posts is typically used to reprocess a volume of posts. For example you changed your Domain name. You now have a large number of posts that link to other topics on your site. They are now broken.

So you use the appropriate rebake process command to replace the old domain name with the new one.

From my understanding since you are just moving from one server to another no rebaking should be required. You will need to update the IP address info pointing to your site in domain provider from my understanding.

The link below should help to give clarity on rebaking posts

So rebaking is basically just fancy name for search&replace?

No, you do the search and replace (if needed), and then the posts need rebaking to convert the raw changes to the cooked, display version.

2 Likes

I have a bit hard time understand the difference here. And I bet it comes from my WordPress/LAMP background as admin/wannabe-webmaster. I miss vital basic knowledge.

Am I understood right (not necessary technically right but end-user level right) that search/replace changes thing in database level, but it isnā€™t visible unless rebaking is done?

Well, I have an all knowing AI on my forum, so I asked.

AI: search&replace vs. rebake

I prompted in Finnish and then asked English translation. That can lead to someā€¦ errors.

ā€”

Search & Replace vs. Rebake in Discourse

Search & Replace

The Search & Replace function, as the name suggests, searches for and replaces specific strings within the forum content. This can be useful, for example, when the siteā€™s domain changes, and you need to update all old domain names with the new ones. The targets for search and replace can be links, words, phrases, or other strings.

Rebake

The term Rebake refers to the process of reprocessing posts in Discourse. Rebaking occurs when posts are converted again from raw text (markdown) to finalized HTML format. This process adheres to the current settings and styling rules. The rebake process can be initiated using commands like rake posts:rebake.

An example of such a setting is add_rel_nofollow_to_user_content, which adds the ā€œrel=nofollowā€ attribute to all external links in user-submitted content unless itā€™s an internal link. If this setting is changed, existing posts need to be rebaked for the change to take effect in those posts.

Why is Just Search & Replace Not Enough?

  • Inconsistency: Simply performing a search & replace might not handle all instances where changes need to be applied. Links may be buried within regular text or hidden in HTML code that the search & replace does not catch.
  • New Rules: If new rules or settings are implemented on the forum, such as add_rel_nofollow_to_user_content, they will not apply to existing posts without rebaking. Applying these new settings to old posts requires rebaking them so the new rules are considered.
  • HTML Formatting: Changing or updating the HTML formatting of posts requires rebaking, as search & replace does not handle HTML formatting as effectively as the rebake process.

Summary

  • Search & Replace: Searches for and replaces specific strings of text but doesnā€™t guarantee comprehensive modification in all instances.
  • Rebake: Reprocesses the posts according to current settings and rules, ensuring a consistent and comprehensive change across all forum content.

I might understand a bit better. But I have a feeling AI wasnā€™t telling the whole truth here.

As one of itā€™s function it is a specialized ā€œsearch & replaceā€. Description fits.Some plugins like affiliate require rebaking if you want the Affiliate plugin to be apply to all previous Amazon links in posts on the site that was posted prior the installing the plugin.

If the Documentation link is not correct in describing the functions clear enough. Then the team should add a direct description.

The rebake command is used for X it differs from Search & replace due to it doing Y when used to replace patterns

Now you have me curious though. So there is a built in search & replace function? And brings the question. If I edit a post is it not so to speak reprocessed? If so shouldnā€™t a search & replace act like an edit & save?

1 Like

Is not there :flushed: Because then AI hallucinate big time.

There is big risk I remember totally wrong. It was a while ago I changed domain of my own. But Iā€™m quite sure I did search&replace. But there is equally big risk Iā€™m mixing things of WordPress and Discourse, and/or I did actually rebaking changing all domaim references.

1 Like

There is a command-line way to ā€œremapā€ certain strings in the database. But there is no feature named ā€˜find and replaceā€™ in Discourse. So yeah, I think your AI is hallucinating and confusing the situation.

Technically, in the ā€˜postsā€™ database table, the post content is stored in two ways:

  1. ā€˜rawā€™ - this is the markdown which was entered by the user
  2. ā€˜cookedā€™ - this is the HTML version of the content, which we render onto the screen

ā€œbakingā€ a post is the process of converting from raw ā†’ cooked. We do it every time a post is created/edited, and when ā€˜rebakingā€™.

One thing the ā€˜bakingā€™ process does is to generate ā€˜optimisedā€™ versions of uploaded images. To save space, those optimised versions are not included in backups. So if you restore a backup, and do not rebake, then you will see broken images on your site. Rebaking is required in order to regnerate those optimised images. Discourse will take care of that automatically when you restore a backup.

4 Likes

I reformulate my question to AI and asked is there such function than search&replace. At that point it explained how to use remap. And after that I got very similar answer than what you gave.

Leading questions are quite basic skills of manipulating AI. But then one must know at least something about topic.

But thanks! Now I understand idea and need of remap and rebake.

(We have dev and similar hereā€¦ we need 101 category of Disourse tech too :woozy_face: )

2 Likes

If youā€™re moving from discourse.org hosting to self-hosted, you need to make sure that your backup includes the uploads and attachments. Until youā€™ve canceled your account or otherwise asked that uploads be included in the backup the backup will point to the uploads on their S3 bucket, which will be deleted soon after your account is closed.

Yes, you typically need to rebake the posts that have attachments after you restore the backup to see that the markdown messages are made into HTML that links to the images on your own server and not theirs.

1 Like