During Restore: "EXCEPTION: You're trying to restore a more recent version of the schema. You should migrate first!"

I recently set up a Discourse server, after spending some time on a trial (trydiscourse.com). When I set it up, I downloaded a backup of the data from our trial from trydiscourse.com, and was able to restore that data on our self-hosted Discourse.

About a week later, when the trial was ending, I downloaded another backup from trydiscourse.com and tried to restore. This time. the restore failed. Here are the logs:

[2022-03-05 01:31:08] [STARTED]

[2022-03-05 01:31:08] 'Joaquin' has started the restore!

[2022-03-05 01:31:08] Marking restore as running...

[2022-03-05 01:31:08] Making sure /var/www/discourse/tmp/restores/default/2022-03-05-013108 exists...

[2022-03-05 01:31:08] Copying archive to tmp directory...

[2022-03-05 01:31:08] Unzipping archive, this may take a while...

[2022-03-05 01:31:08] Extracting dump file...

[2022-03-05 01:31:08] Validating metadata...

[2022-03-05 01:31:08]   Current version: 20220220234155

[2022-03-05 01:31:08]   Restored version: 20220223161000

[2022-03-05 01:31:08] EXCEPTION: You're trying to restore a more recent version of the schema. You should migrate first!

[2022-03-05 01:31:08] /var/www/discourse/lib/backup_restore/meta_data_handler.rb:31:in `validate'

/var/www/discourse/lib/backup_restore/restorer.rb:112:in `validate_backup_metadata'

/var/www/discourse/lib/backup_restore/restorer.rb:43:in `run'

/var/www/discourse/script/spawn_backup_restore.rb:23:in `restore'

/var/www/discourse/script/spawn_backup_restore.rb:36:in `block in <main>'

/var/www/discourse/script/spawn_backup_restore.rb:4:in `fork'

/var/www/discourse/script/spawn_backup_restore.rb:4:in `<main>'

[2022-03-05 01:31:08] Trying to rollback...

[2022-03-05 01:31:08] There was no need to rollback

[2022-03-05 01:31:08] Cleaning stuff up...

[2022-03-05 01:31:08] Removing tmp '/var/www/discourse/tmp/restores/default/2022-03-05-013108' directory...

[2022-03-05 01:31:08] Marking restore as finished...

[2022-03-05 01:31:08] Notifying 'Joaquin' of the end of the restore...

What I have gathered so far from my research is that the “schema” that the exception says I should “migrate first!” has something to do with the database that Discourse uses.

I have looked around on Discourse Meta, and have not seen anyone talking about this. I also updated Discourse to the latest version and then tried to restore again, but that had the same result. I poked around in the Discourse files to see if there was a relevant tool that might help, but didn’t see anything that looked promising.

My best guess right now is that during that week after I set up our self-hosted Discourse, something was changed with our trial forum on trydiscourse.com.

My questions are:

  1. How can I do the migration that the error suggests?
  2. What exactly caused this restore failure? Is this something that would ever happen normally (not during a transition from trial to self-hosted)?

Thanks in advance for any assistance with this! :slightly_smiling_face:

1 Like

You should make sure that you rebuild your self hosted instance with at least the same plugins that have been installed on your trial.

Alternatively, if you feel adventurous, you could rename your backup file, replacing 20220223161000 with 20220220234155 in the file name.

6 Likes

I encountered the same issue a few days ago. The search feature quickly led me to the solution:

(same as @RGJ by the way).

3 Likes

Thanks for the replies! That is very helpful :heart:

I am still curious about how to do the migration, but it sounds like that may not be needed.

2 Likes