kuyashi
(David O'Dea)
16 Septiembre, 2016 16:57
1
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 me gusta
cpradio
(cpradio)
16 Septiembre, 2016 17:22
2
I maybe wrong, but it may be related to this
render nothing: true, status: status
end
def upload_backup_chunk
filename = params.fetch(:resumableFilename)
total_size = params.fetch(:resumableTotalSize).to_i
return render status: 415, text: I18n.t("backup.backup_file_should_be_tar_gz") unless /\.(tar\.gz|t?gz)$/i =~ filename
return render status: 415, text: I18n.t("backup.not_enough_space_on_disk") unless has_enough_space_on_disk?(total_size)
return render status: 415, text: I18n.t("backup.invalid_filename") unless !!(/^[a-zA-Z0-9\.-_]+$/ =~ filename)
file = params.fetch(:file)
identifier = params.fetch(:resumableIdentifier)
chunk_number = params.fetch(:resumableChunkNumber).to_i
chunk_size = params.fetch(:resumableChunkSize).to_i
current_chunk_size = params.fetch(:resumableCurrentChunkSize).to_i
# path to chunk file
chunk = Backup.chunk_path(identifier, filename, chunk_number)
# upload chunk
From this commit:
committed 03:58AM - 16 Sep 16 UTC
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.
expect(response.status).to eq(415)
expect(response.body).to eq(I18n.t('backup.invalid_filename'))
end
end
end
describe "when filename is valid" do
it "should upload the file successfully" do
xhr :post, :upload_backup_chunk,
resumableFilename: 'test.tar.gz',
resumableTotalSize: '1',
resumableIdentifier: 'test',
resumableChunkNumber: '1',
resumableChunkSize: '1',
resumableCurrentChunkSize: '1',
file: fixture_file_upload(Tempfile.new)
expect(response.status).to eq(200)
expect(response.body).to eq("")
end
3 Me gusta
kuyashi
(David O'Dea)
16 Septiembre, 2016 17:36
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
cpradio
(cpradio)
16 Septiembre, 2016 17:38
4
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 Me gusta
pfaffman
(Jay Pfaffman)
16 Septiembre, 2016 18:40
6
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.
kuyashi
(David O'Dea)
16 Septiembre, 2016 19:07
7
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)>
pfaffman
(Jay Pfaffman)
16 Septiembre, 2016 19:08
8
That’s what you got when you did a ./launcher rebuild app? (I left out that step).
pfaffman
(Jay Pfaffman)
16 Septiembre, 2016 19:13
10
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 me gusta
kuyashi
(David O'Dea)
16 Septiembre, 2016 19:16
11
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 me gusta
cpradio
(cpradio)
16 Septiembre, 2016 19:22
12
PR Submitted: (I got out of my meeting early)
master ← cpradio:fix-backup-validation
5 Me gusta
kuyashi
(David O'Dea)
16 Septiembre, 2016 19:23
13
Thank you kindly @cpradio