# Failed to restore from the backup

**URL:** https://meta.discourse.org/t/failed-to-restore-from-the-backup/270015
**Category:** Self-hosting
**Tags:** backups
**Created:** [June 29, 2023, 12:02pm UTC](https://meta.discourse.org/t/failed-to-restore-from-the-backup/270015 "2023-06-29T12:02:31Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![klein](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/klein/32/310191_2.png) [@klein](https://meta.discourse.org/u/klein)
#### Post date: [June 29, 2023, 12:02pm UTC](https://meta.discourse.org/t/failed-to-restore-from-the-backup/270015/1 "2023-06-29T12:02:31Z")

</div>

I tried [Restore a backup from the command line](https://meta.discourse.org/t/restore-a-backup-from-the-command-line/108034) but i got following:

```plaintext
root@my_server:/var/www/discourse# discourse restore my_server-2023-06-20-033008-v20210922064213.tar.gz
Starting restore: my_server-2023-06-20-033008-v20210922064213.tar.gz
[STARTED]
'system' has started the restore!
Marking restore as running...
Making sure /var/www/discourse/tmp/restores/default/2023-06-29-113408 exists...
Copying archive to tmp directory...
Unzipping archive, this may take a while...
EXCEPTION: /var/www/discourse/lib/discourse.rb:137:in `exec': Failed to decompress archive.

gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now
/var/www/discourse/lib/discourse.rb:171:in `execute_command'
/var/www/discourse/lib/discourse.rb:137:in `exec'
/var/www/discourse/lib/discourse.rb:33:in `execute_command'
/var/www/discourse/lib/backup_restore/backup_file_handler.rb:78:in `decompress_archive'
/var/www/discourse/lib/backup_restore/backup_file_handler.rb:23:in `decompress'
/var/www/discourse/lib/backup_restore/restorer.rb:42:in `run'
script/discourse:149:in `restore'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/thor-1.2.2/lib/thor/command.rb:27:in `run'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/thor-1.2.2/lib/thor/invocation.rb:127:in `invoke_command'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/thor-1.2.2/lib/thor.rb:392:in `dispatch'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/thor-1.2.2/lib/thor/base.rb:485:in `start'
script/discourse:290:in `<top (required)>'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.13/lib/bundler/cli/exec.rb:58:in `load'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.13/lib/bundler/cli/exec.rb:58:in `kernel_load'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.13/lib/bundler/cli/exec.rb:23:in `run'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.13/lib/bundler/cli.rb:492:in `exec'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.13/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.13/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.13/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.13/lib/bundler/cli.rb:34:in `dispatch'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.13/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.13/lib/bundler/cli.rb:28:in `start'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.13/exe/bundle:45:in `block in <top (required)>'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.13/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.13/exe/bundle:33:in `<top (required)>'
/usr/local/bin/bundle:25:in `load'
/usr/local/bin/bundle:25:in `<main>'
Trying to rollback...
There was no need to rollback
Cleaning stuff up...
Removing tmp '/var/www/discourse/tmp/restores/default/2023-06-29-113408' directory...
Marking restore as finished...
Notifying 'system' of the end of the restore...
Finished!
[FAILED]
Restore done.

```

What should i do now? I really appreciate it if there is any advice.

---

<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: [June 29, 2023, 2:13pm UTC](https://meta.discourse.org/t/failed-to-restore-from-the-backup/270015/2 "2023-06-29T14:13:13Z")

</div>

> [@klein](#):
>
> ```plaintext
> gzip: stdin: not in gzip format
> 
> ```

There is a problem with your backup file. Try downloading it again.

---

<div class="post-metadata">

### Author: ![Ed\_S](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ed_s/32/134015_2.png) [@Ed\_S](https://meta.discourse.org/u/Ed_S)
#### Post date: [June 29, 2023, 2:53pm UTC](https://meta.discourse.org/t/failed-to-restore-from-the-backup/270015/3 "2023-06-29T14:53:09Z")

</div>

I think it’s possible in some situations that downloading the backup will have uncompressed it. In which case the thing to do is to compress it with gzip, perhaps with something like

```plaintext
mv my_server-2023-06-20-033008-v20210922064213.tar.gz my_server-2023-06-20-033008-v20210922064213.tar
gzip my_server-2023-06-20-033008-v20210922064213.tar

```

But do be careful: have a safe copy of your backup, on at least two computers, at all times. You do not want to lose or damage your only backup.

You can use `file` to find the type of a file:

```plaintext
# file thing
thing: gzip compressed data, last modified: Thu ... 2023, from Unix
# file otherthing
otherthing: POSIX tar archive (GNU)

```

---

<div class="post-metadata">

### Author: ![klein](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/klein/32/310191_2.png) [@klein](https://meta.discourse.org/u/klein)
#### Post date: [July 5, 2023, 12:16am UTC](https://meta.discourse.org/t/failed-to-restore-from-the-backup/270015/4 "2023-07-05T00:16:39Z")

</div>

Yes, you are right the backupfile is in a wrong format.

---

<div class="post-metadata">

### Author: ![klein](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/klein/32/310191_2.png) [@klein](https://meta.discourse.org/u/klein)
#### Post date: [July 5, 2023, 12:19am UTC](https://meta.discourse.org/t/failed-to-restore-from-the-backup/270015/5 "2023-07-05T00:19:43Z")

</div>

yes, you are right. When i tried to restore from a backup with .tar format, it failed. But with .tar.gz, it worked!

---

<div class="post-metadata">

### Author: ![klein](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/klein/32/310191_2.png) [@klein](https://meta.discourse.org/u/klein)
#### Post date: [July 5, 2023, 12:25am UTC](https://meta.discourse.org/t/failed-to-restore-from-the-backup/270015/6 "2023-07-05T00:25:34Z")

</div>

Thank you so much for helping me! The problem is that I downloaded the backup file with a mac os and the backup file turned into .tar format which should be .tar.gz format. I restore my forum successfully with the backup.tar.gz. 😊
