How to "migrate" Discourse to Discourse without Site Settings


(Daniela) #1

We need to migrate all our database to a new bigger server (digital ocean).
We need to import only the database (users, passwords, posts, topics etc…) but we don’t want import the site settings, so we can’t use the normal way (backup restore).

That’s because in our installation the old admin delete some categories (like staff and lounge) and probably other things. Originally it was a trial installation to test Discourse so many settings have been touched or changed or even deleted and, I don’t know why, he has decided to make the forum public without a fresh installation.

Is it possible to do that in a easy way (if so, possibly step-by-step) to have a new fresh installation without lost all our data?


Backup only Site Settings
(Jeff Atwood) #2

I do not think there is any way to import everything except the site settings.


(Mittineague) #3

Might it be possible to truncate the site_settings table prior to doing an import?

Of course that would still leave the mess caused by deleting and renaming categories, but it should help a bit.


(charles) #4

Curious if there exist something like wp.

Export content, install new, import.


(Daniela) #5

Can you explain how to do that?
We can try it in our (local) test site, just installed to make some experimentations.

With bulk selection this isn’t a big problem for us (of course we lost some days to do that)


(Mittineague) #6

Save a backup of course.

Once you open the database CLI run the query

TRUNCATE site_settings

AFAIK there are no FKs involved, but maybe the optional CASCADE wouldn’t hurt.

https://www.postgresql.org/docs/9.1/static/sql-truncate.html


(Daniela) #7

So I need to:

  1. unzip a backup
  2. open the folder with postgres
  3. truncate the site_settings
    (somenthing like
    psql -U username -d mydatabase -c TRUNCATE site_settings
    or
    psql -U username -d mydatabase -c 'TRUNCATE' site_settings)
  4. zip again the backup
  5. restore the backup and pray

Is all correct @Mittineague?


(Daniela) #8

Done.

Now we have a new test installation without site settings (except “notification mail”)
We still have our data, plugins, groups and categories, and our personal customization (css, html and js).

But I have the same trouble, staff and lounge categories were not created.

The only category that was created is Uncategorized (now I have 2 categories Uncategorized).

Any idea?


(Daniela) #9

Sorry, but where I can find the staff_category_id ? I tried on /site.json (here on Meta too) and I can see the id for all the settings except for stuff category.
Is it a hidden id?
Where I can find it?

Thanks


(Kane York) #10

It’s a “hidden” site setting - you can only set it from the Rails console, I think?


Analyzing Discourse Performance using NGINX logs