Failed when using backups to restore

AI-generated summary

Failed Restore Due to Schema Version Mismatch

mikeguo attempted to restore a backup in a local temporary instance but encountered an error. The logs revealed a schema version mismatch between the current version (20221205225450) and the restored version (20221212234948). JammyDodger pointed out that the issue is due to the instance being restored to not being updated to the latest version. To resolve the issue, the instance needs to be updated before performing the restore.

To avoid loss of data, before importing data completely by script, I make production instance backup, download it to local, and try to restore it in local temporary instance, however failed.

And logs as below

[2022-12-14 21:58:40] 'm11' has started the restore!
[2022-12-14 21:58:40] Marking restore as running...
[2022-12-14 21:58:40] Making sure /Users/mike/otherprojects/discourse/tmp/restores/default/2022-12-14-135840 exists...
[2022-12-14 21:58:40] Copying archive to tmp directory...
[2022-12-14 21:58:40] Unzipping archive, this may take a while...
[2022-12-14 21:58:40] Extracting dump file...
[2022-12-14 21:58:40] Validating metadata...
[2022-12-14 21:58:40]   Current version: 20221205225450
[2022-12-14 21:58:40]   Restored version: 20221212234948
[2022-12-14 21:58:40] EXCEPTION: You're trying to restore a more recent version of the schema. You should migrate first!
[2022-12-14 21:58:40] /Users/mike/otherprojects/discourse/lib/backup_restore/meta_data_handler.rb:31:in `validate'
/Users/mike/otherprojects/discourse/lib/backup_restore/restorer.rb:112:in `validate_backup_metadata'
/Users/mike/otherprojects/discourse/lib/backup_restore/restorer.rb:43:in `run'
/Users/mike/otherprojects/discourse/script/spawn_backup_restore.rb:23:in `restore'
/Users/mike/otherprojects/discourse/script/spawn_backup_restore.rb:36:in `block in <main>'
/Users/mike/otherprojects/discourse/script/spawn_backup_restore.rb:4:in `fork'
/Users/mike/otherprojects/discourse/script/spawn_backup_restore.rb:4:in `<main>'
[2022-12-14 21:58:40] Trying to rollback...
[2022-12-14 21:58:40] There was no need to rollback
[2022-12-14 21:58:40] Cleaning stuff up...
[2022-12-14 21:58:40] Removing tmp '/Users/mike/otherprojects/discourse/tmp/restores/default/2022-12-14-135840' directory...
[2022-12-14 21:58:40] Marking restore as finished...
[2022-12-14 21:58:40] Notifying 'm11' of the end of the restore...
[2022-12-14 21:58:42] Finished!

You need to update the instance you’re restoring the back-up to to the latest version before doing the restore. :+1: