无法从CLI恢复备份

你好,

我正在尝试恢复备份,但一直收到此错误:

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.

我不确定为什么会这样说,备份是我拉取时未修改过的。谢谢。

Web上出现相同错误。

这可能是关键错误。您是否尝试过验证备份没有损坏?我认为这会起作用

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

同样的问题。我无法获得新的备份,因为服务器的 RAID 配置早已丢失,但我需要这些数据。

image

已检查备份。看起来是有效的。

这是在您正在恢复备份的同一台计算机上吗?文件可能未完成传输或在传输过程中损坏。

备份在我的 Windows PC 上,我正在使用 scp:

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

两个文件的校验和是否匹配?(关于如何生成校验和的说明请参见此处。)

1 个赞

看起来是这样。我会继续用 WinRAR 挖掘一下,但如果你有什么建议,我很感激。我在那里也会收到同样的警告,但在 VSCode 中却能正常显示。

如果这有帮助,pigz 显示:

/blackiron-2022-12-03-163112-v20221201035918.tar.gz 到 <stdout> pigz: 跳过: /blackiron-2022-12-03-163112-v20221201035918.tar.gz: 已损坏 -- 不完整的 deflate 数据

我在这方面没有太多经验。如果你能拿到文件的副本,你应该能够创建一个新的备份文件来复制过去。

我尝试编写自己的脚本来修复它,但没有成功。

我对 gzips 也不太了解,所以也无能为力。如果有人知道如何使用完整的 sql 脚本和上传文件来恢复它,请告诉我。SQL 脚本看起来没问题,上传文件也没问题。

更新:我已成功恢复了该网站的旧版本,大约是两个月前的。仍然希望能够恢复较新的版本。

这是个好消息。我找到了一个建议,建议使用gzip Recovery Toolkit,这听起来很有希望。

2 个赞

遵循了此指南并进行了移动,但遇到了此错误:

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

很有可能是文件被其他用户拥有。ls -l /var/www/discourse/public/backups/default/blackiron-2022-12-03-163112-v20221201035918.tar.gz' 可能会显示问题。

1 个赞

它显示它是 root 用户拥有的。我需要将其设置为 discourse 用户吗?

编辑:看起来该工具造成了更多损坏。