# Cannot upload a downloaded backup

**URL:** https://meta.discourse.org/t/cannot-upload-a-downloaded-backup/50250
**Category:** Bug
**Created:** [September 16, 2016, 4:57pm UTC](https://meta.discourse.org/t/cannot-upload-a-downloaded-backup/50250 "2016-09-16T16:57:00Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![kuyashi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kuyashi/32/82068_2.png) [@kuyashi](https://meta.discourse.org/u/kuyashi)
#### Post date: [September 16, 2016, 4:57pm UTC](https://meta.discourse.org/t/cannot-upload-a-downloaded-backup/50250/1 "2016-09-16T16:57:00Z")

</div>

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 ?

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [September 16, 2016, 5:22pm UTC](https://meta.discourse.org/t/cannot-upload-a-downloaded-backup/50250/2 "2016-09-16T17:22:52Z")

</div>

I maybe wrong, but it may be related to this

> <https://github.com/discourse/discourse/blob/512922d7767c84615b8b77089e34ede244a88c7f/app/controllers/admin/backups_controller.rb#L122>

From this commit:  
[https://github.com/discourse/discourse/commit/512922d7767c84615b8b77089e34ede244a88c7f](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.

> <https://github.com/discourse/discourse/blob/512922d7767c84615b8b77089e34ede244a88c7f/spec/controllers/admin/backups_controller_spec.rb#L212>

---

<div class="post-metadata">

### Author: ![kuyashi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kuyashi/32/82068_2.png) [@kuyashi](https://meta.discourse.org/u/kuyashi)
#### Post date: [September 16, 2016, 5:36pm UTC](https://meta.discourse.org/t/cannot-upload-a-downloaded-backup/50250/3 "2016-09-16T17:36:30Z")

</div>

@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`

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [September 16, 2016, 5:38pm UTC](https://meta.discourse.org/t/cannot-upload-a-downloaded-backup/50250/4 "2016-09-16T17:38:41Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![kuyashi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kuyashi/32/82068_2.png) [@kuyashi](https://meta.discourse.org/u/kuyashi)
#### Post date: [September 16, 2016, 5:50pm UTC](https://meta.discourse.org/t/cannot-upload-a-downloaded-backup/50250/5 "2016-09-16T17:50:53Z")

</div>

many thanks @cpradio

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [September 16, 2016, 6:40pm UTC](https://meta.discourse.org/t/cannot-upload-a-downloaded-backup/50250/6 "2016-09-16T18:40:58Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![kuyashi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kuyashi/32/82068_2.png) [@kuyashi](https://meta.discourse.org/u/kuyashi)
#### Post date: [September 16, 2016, 7:07pm UTC](https://meta.discourse.org/t/cannot-upload-a-downloaded-backup/50250/7 "2016-09-16T19:07:01Z")

</div>

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

```plaintext
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)>

```

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [September 16, 2016, 7:08pm UTC](https://meta.discourse.org/t/cannot-upload-a-downloaded-backup/50250/8 "2016-09-16T19:08:42Z")

</div>

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

---

<div class="post-metadata">

### Author: ![kuyashi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kuyashi/32/82068_2.png) [@kuyashi](https://meta.discourse.org/u/kuyashi)
#### Post date: [September 16, 2016, 7:09pm UTC](https://meta.discourse.org/t/cannot-upload-a-downloaded-backup/50250/9 "2016-09-16T19:09:00Z")

</div>

Yes, thats correct ..

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [September 16, 2016, 7:13pm UTC](https://meta.discourse.org/t/cannot-upload-a-downloaded-backup/50250/10 "2016-09-16T19:13:04Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![kuyashi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kuyashi/32/82068_2.png) [@kuyashi](https://meta.discourse.org/u/kuyashi)
#### Post date: [September 16, 2016, 7:16pm UTC](https://meta.discourse.org/t/cannot-upload-a-downloaded-backup/50250/11 "2016-09-16T19:16:28Z")

</div>

~~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

> [@pfaffman](#):
>
> I suppose you could try
> 
> version: f63a797e390ed79b643cfad42837a67068549fbf
> 
> which is the last checkin before the filename validation one.

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [September 16, 2016, 7:22pm UTC](https://meta.discourse.org/t/cannot-upload-a-downloaded-backup/50250/12 "2016-09-16T19:22:32Z")

</div>

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

---

<div class="post-metadata">

### Author: ![kuyashi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kuyashi/32/82068_2.png) [@kuyashi](https://meta.discourse.org/u/kuyashi)
#### Post date: [September 16, 2016, 7:23pm UTC](https://meta.discourse.org/t/cannot-upload-a-downloaded-backup/50250/13 "2016-09-16T19:23:46Z")

</div>

Thank you kindly @cpradio

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [September 16, 2016, 8:53pm UTC](https://meta.discourse.org/t/cannot-upload-a-downloaded-backup/50250/14 "2016-09-16T20:53:00Z")

</div>


