Cannot upload a downloaded backup

AI-generated summary

User kuyashi reported a bug preventing the restoration of a downloaded backup to a new Discourse instance. The system initially rejected the filename due to “invalid characters,” and after renaming, it failed with an error stating the “Migration version is missing.” User cpradio identified the issue as a flawed regular expression in the backup controller that incorrectly interpreted hyphens as character ranges. They suggested that the core logic requires adjustment and proposed a temporary workaround of replacing hyphens with underscores. User pfaffman offered an alternative short-term solution: downgrading the Discourse version in app.yml to a specific commit prior to the validation change. kuyashi initially encountered a scheduler error when attempting this downgrade but, after pfaffman clarified the need for a rebuild, successfully restored the instance by reverting to commit f63a797e390ed79b643cfad42837a67068549fbf kuyashi. Meanwhile, cpradio submitted a pull request to permanently fix the filename validation logic, which kuyashi acknowledged with gratitude.

I want to move my discourse instance to a new server, however when I download a backup form current server and try to upload to new server, I get the following:

There has been an error while uploading ‘cs-uni-2016-09-16-155132-v20160905092148.tar.gz’: The backup filename contains invalid characters. Valid characters are a-z 0-9 . - _.

So I changed the backup filename to something that was accepted, is that why I am getting:

EXCEPTION: Migration version is missing from the filename.

Why doesn’t discourse accept uploads for restore ?

「いいね!」 1

I maybe wrong, but it may be related to this

From this commit:
https://github.com/discourse/discourse/commit/512922d7767c84615b8b77089e34ede244a88c7f

And the fact that - may need to be escaped like . is. Alternatively, if you list - at the very end, it should work too but being between two characters, it thinks it is trying to define a range.

So either
/^[a-zA-Z0-9\.\-_]+$/ or /^[a-zA-Z0-9\._-]+$/ should work

Thoughts @tgxworld?

Also, I think it would be better to make the test, use ‘test_Site-0123456789.tar.gz’ so that it utilizes all of the characters you are permitting.

「いいね!」 3

@cpradio thanks for the input.

what would I change this backup filename to in order to have it be accepted: ?

cs-uni-2016-09-16-172539-v20160905092148.tar.gz

You wouldn’t. Core needs to adjust its logic. Then you’d get latest and it will upload just fine.

One thing you can try, and this is purely a guess to get you around the current issue, is replace the ‘-’ (a hyphen) with ‘_’ (an underscore).

I can’t promise that will work, but it “might”.

Edit:
I’ve got a meeting to get to, and then heading home. If I have time tonight and it is still unresolved, I’ll submit the PR to fix it.

「いいね!」 3

many thanks @cpradio

The short-term answer is to edit app.yml and replace

version: stable

with

version: f7a335a64e7146166d5fdaedcfee816997f2822d

That’ll put you back to 1.6.1 and you’re good to go!

You’ll need to remember to change it back to tests-passed after it gets bumpted to 1.6.3, however!

Oh! If you were on tests-passed wait for me to edit this. . .,

version: b3c65620f341df95c58043dd5f120f5f43e62e3e

should take you back to beta3.

Thanks @pfaffman, but i tried that and it fails with the following in the logs:

Job exception: undefined method `every' for Jobs::MigrateUploadScheme:Class

/var/www/discourse/lib/scheduler/schedule_info.rb:79:in `schedule!'
/var/www/discourse/lib/scheduler/manager.rb:270:in `schedule_next_job'
/var/www/discourse/lib/scheduler/manager.rb:248:in `block in tick'
/var/www/discourse/lib/scheduler/manager.rb:295:in `block in lock'
/var/www/discourse/lib/distributed_mutex.rb:21:in `synchronize'
/var/www/discourse/lib/scheduler/manager.rb:294:in `lock'
/var/www/discourse/lib/scheduler/manager.rb:247:in `tick'
/var/www/discourse/config/initializers/100-sidekiq.rb:35:in `block (2 levels) in <top (required)>

That’s what you got when you did a ./launcher rebuild app? (I left out that step).

Yes, thats correct ..

Well, darn. I’m operating at the edge of my expertise, but the

version: f7a335a64e7146166d5fdaedcfee816997f2822d

worked for me when I did my rebuild on stable

I suppose you could try

version: f63a797e390ed79b643cfad42837a67068549fbf

which is the last checkin before the filename validation one.

「いいね!」 1

Much appreciated! i’ll try your last advice and let you know, thanks.

The following worked as a fixed pending the PR merge from @cpradio

「いいね!」 1

PR Submitted: (I got out of my meeting early)
https://github.com/discourse/discourse/pull/4444/commits/0d2d8797b6c45d5a1d261170da31674a230643bb

「いいね!」 5

Thank you kindly @cpradio