Failed to restore from the backup

I tried Restore a backup from the command line but i got following:

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.

1 Like

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

2 Likes

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

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:

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

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

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

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. :blush:

2 Likes