Cannot restore backup from cli

Hello,

I’m trying to restore a backup and I keep getting this error:

Starting restore: blackiron-2022-12-03-163112-v20221201035918.tar.gz
[STARTED]
'system' has started the restore!
Marking restore as running...
Making sure /var/www/discourse/tmp/restores/default/2023-11-28-040817 exists...
Copying archive to tmp directory...
Unzipping archive, this may take a while...
EXCEPTION: /var/www/discourse/lib/discourse.rb:138:in `exec': Failed to decompress archive.

gzip: stdin: unexpected end of file
tar: Unexpected EOF in archive
tar: Unexpected EOF in archive
tar: Error is not recoverable: exiting now
/var/www/discourse/lib/discourse.rb:172:in `execute_command'
/var/www/discourse/lib/discourse.rb:138:in `exec'
/var/www/discourse/lib/discourse.rb:34: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.3.0/lib/thor/command.rb:28:in `run'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/thor-1.3.0/lib/thor/invocation.rb:127:in `invoke_command'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/thor-1.3.0/lib/thor.rb:527:in `dispatch'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/thor-1.3.0/lib/thor/base.rb:584: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-11-28-040817' directory...
Marking restore as finished...
Notifying 'system' of the end of the restore...
Finished!
[FAILED]
Restore done.

I’m not sure why it says that, the backup is unmodified from when I pulled it. Thank you.

Same error on web.

This is likely the critical error. Have you tried verifying the backup isn’t corrupt? I think this would work:

$ gunzip -c  blackiron-2022-12-03-163112-v20221201035918.tar.gz | tar -t > /dev/null
1 Like

Same issue. I can’t get a new backup because the RAID config for the server is long gone but I need this data.

Checked inside of the backup. Seems to be valid.

Is this on the same machine that you are restoring the backup on? It’s possible the file didn’t finish transferring or otherwise got corrupted in transit.

The backup is on my Windows PC, and I am using scp:

scp blackiron-2022-12-03-163112-v20221201035918.tar.gz root@#.#.#.#:/var/discourse/shared/standalone/backups/default

Does the checksum match on both files? (Instructions for generating a checksum here.)

1 Like

It’d seem like it. I’ll keep doing some digging with WinRAR but if you have any suggestions it’d be appreciated. I get the same warning there too, but I can see it in VSCode fine.

image

If this helps, pigz shows:

/blackiron-2022-12-03-163112-v20221201035918.tar.gz to <stdout> pigz: skipping: /blackiron-2022-12-03-163112-v20221201035918.tar.gz: corrupted -- incomplete deflate data

I don’t have much experience there. If you can get a copy of the files, you should be able to create a new backup file to copy over.

I tried writing my own script to fix it which didn’t work.

I’m also not an expert with gzips, so not much I can do either. If anybody else knows how I can restore it with full access to the sql script and uploads then please let me know. SQL script is fine at a glance and the uploads are fine as well.

Update: I was able to successfully restore an older version of the site, by about 2 months. Still looking to get the new(er) one on.

That’s good news. I found a suggestion to use The gzip Recovery Toolkit, which sounds promising.

2 Likes

Followed this guide and moved it and got this error:

root@ftsweb-app:/var/www/discourse# discourse restore blackiron-2022-12-03-163112-v20221201035918.tar.gz
Starting restore: blackiron-2022-12-03-163112-v20221201035918.tar.gz
[STARTED]
'system' has started the restore!
Marking restore as running...
Making sure /var/www/discourse/tmp/restores/default/2023-11-28-060452 exists...
Copying archive to tmp directory...
EXCEPTION: /var/www/discourse/lib/discourse.rb:138:in `exec': Failed to copy archive to tmp directory.
cp: cannot open '/var/www/discourse/public/backups/default/blackiron-2022-12-03-163112-v20221201035918.tar.gz' for reading: Permission denied

Good chance the file is owned by another user. ls -l /var/www/discourse/public/backups/default/blackiron-2022-12-03-163112-v20221201035918.tar.gz' would show the problem, probably.

1 Like

It says that root owns it. Do I need to make it the discourse user?

Edit: seems like the tool did more damage.