感谢您的帮助!
我已从仍完全正常运行的旧生产服务器创建了新备份。
已在新阶段服务器上清除了 Docker 和 Discourse。按照官方说明重新安装了 Docker 和 Discourse。随后执行了命令行恢复说明。
该备份是使用 docker-engine 17.05.0~ce-0~debian-stretch 创建的,而恢复环境使用的是 docker-ce-cli 5:19.03.9~3-0~debian-buster。这也导致了 PostgreSQL 版本的更新(旧版本:10;新版本:12)。
备份过时的 Docker/PostgreSQL 版本,然后尝试在最新版本的 Docker/Discourse 安装上进行恢复,这种做法是否合理?
这次遇到了不同的错误。
ERROR: could not create unique index "index_incoming_referers_on_path_and_incoming_domain_id"
DETAIL: Key (path, incoming_domain_id)=(/wiki/Tor_Browser, 3) is duplicated.
EXCEPTION: psql failed: DETAIL: Key (path, incoming_domain_id)=(/wiki/Tor_Browser, 3) is duplicated.
完整日志:
root@whonix-app:/var/www/discourse# discourse restore whonix-forum-2020-05-25-065253-v20200506044956.tar.gz
Starting restore: whonix-forum-2020-05-25-065253-v20200506044956.tar.gz
[STARTED]
'system' has started the restore!
Marking restore as running...
Making sure /var/www/discourse/tmp/restores/default/2020-05-25-132224 exists...
Copying archive to tmp directory...
Unzipping archive, this may take a while...
Extracting dump file...
Validating metadata...
Current version: 20200524181959
Restored version: 20200506044956
Enabling readonly mode...
Pausing sidekiq...
Waiting up to 60 seconds for Sidekiq to finish running jobs...
Creating missing functions in the discourse_functions schema...
Restoring dump file... (this may take a while)
[cut]
ALTER TABLE
[cut lots of duplicate ALTER TABLE lines]
ALTER TABLE
CREATE INDEX
[cut lots of duplicate CREATE INDEX lines]
CREATE INDEX
ERROR: could not create unique index "index_incoming_referers_on_path_and_incoming_domain_id"
DETAIL: Key (path, incoming_domain_id)=(/wiki/Tor_Browser, 3) is duplicated.
EXCEPTION: psql failed: DETAIL: Key (path, incoming_domain_id)=(/wiki/Tor_Browser, 3) is duplicated.
/var/www/discourse/lib/backup_restore/database_restorer.rb:95:in `restore_dump'
/var/www/discourse/lib/backup_restore/database_restorer.rb:26:in `restore'
/var/www/discourse/lib/backup_restore/restorer.rb:49:in `run'
script/discourse:143:in `restore'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/thor-1.0.1/lib/thor/command.rb:27:in `run'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/thor-1.0.1/lib/thor/invocation.rb:127:in `invoke_command'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/thor-1.0.1/lib/thor.rb:392:in `dispatch'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/thor-1.0.1/lib/thor/base.rb:485:in `start'
script/discourse:284:in `<top (required)>'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `load'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `kernel_load'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:28:in `run'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli.rb:476:in `exec'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor.rb:399:in `dispatch'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli.rb:30:in `dispatch'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/base.rb:476:in `start'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli.rb:24:in `start'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/exe/bundle:46:in `block in <top (required)>'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/friendly_errors.rb:123:in `with_friendly_errors'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/exe/bundle:34:in `<top (required)>'
/usr/local/bin/bundle:23:in `load'
/usr/local/bin/bundle:23:in `<main>'
Trying to rollback...
Rolling back...
Cleaning stuff up...
Dropping functions from the discourse_functions schema...
Removing tmp '/var/www/discourse/tmp/restores/default/2020-05-25-132224' directory...
Unpausing sidekiq...
Disabling readonly mode...
Marking restore as finished...
Notifying 'system' of the end of the restore...
Finished!
[FAILED]
Restore done.
root@whonix-app:/var/www/discourse#
我想知道这怎么可能,因为我的旧生产 Discourse 服务器仍然完全正常运行。而且这是我尝试的第二个备份。
是 PostgreSQL 10 还是 PostgreSQL 12?
编辑:
root@whonix-app:/var/www/discourse# rails c
[1] pry(main)> IncomingReferer.where(path: "/wiki/Tor_Browser")
=> [#<IncomingReferer:0x0000561cba422f48
id: 11361,
path: "/wiki/Tor_Browser",
incoming_domain_id: 3>]
[2] pry(main)>
编辑 2:
[6] pry(main)> IncomingReferer.where("path LIKE '%/wiki/Tor_Browser%'")
=> [#<IncomingReferer:0x0000561cc08882a8
id: 19,
path: "/wiki/Tor_Browser",
incoming_domain_id: 3>,
#<IncomingReferer:0x0000561cc08b3f48
id: 67,
path: "/wiki/Tor_Browser/Download_Confirmation_Screen",
incoming_domain_id: 3>,
#<IncomingReferer:0x0000561cc08b3e08
id: 331,
path: "/wiki/Tor_Browser/Internal_Updater",
incoming_domain_id: 3>,
#<IncomingReferer:0x0000561cc08b3cf0
id: 489,
path: "/wiki/Tor_Browser",
<page break> --- 按回车键继续(按 q<enter> 退出) --- <page break>
incoming_domain_id: 113>,
#<IncomingReferer:0x0000561cc08b3bb0
id: 2957,
path: "/wiki/Tor_Browser/Advanced_Users",
incoming_domain_id: 617>,
#<IncomingReferer:0x0000561cc08b3a70
id: 4052,
path: "/wiki/Tor_Browser",
incoming_domain_id: 617>,
#<IncomingReferer:0x0000561cc08b38e0
id: 4196,
path: "/wiki/Tor_Browser",
incoming_domain_id: 1513>,
#<IncomingReferer:0x0000561cc08b37f0
id: 4220,
<page break> --- 按回车键继续(按 q<enter> 退出) --- <page break>
path: "/wiki/Tor_Browser/Advanced_Users",
incoming_domain_id: 1513>,
#<IncomingReferer:0x0000561cc08b3700
id: 4307,
path: "/wiki/Tor_Browser",
incoming_domain_id: 1552>,
#<IncomingReferer:0x0000561cc08b34a8
id: 4346,
path: "/wiki/Tor_Browser/Advanced_Users",
incoming_domain_id: 1552>,
#<IncomingReferer:0x0000561cc08b3318
id: 8713,
path: "/wiki/Tor_Browser/Advanced_Users",
incoming_domain_id: 3>,
#<IncomingReferer:0x0000561cc08b3188
<page break> --- 按回车键继续(按 q<enter> 退出) --- <page break>
id: 9746,
path: "/wiki/Tor_Browser_without_Tor",
incoming_domain_id: 3>,
#<IncomingReferer:0x0000561cc08b2f08
id: 10248,
path: "/wiki/Tor_Browser_without_Tor",
incoming_domain_id: 113>,
#<IncomingReferer:0x0000561cc08b2cb0
id: 11361,
path: "/wiki/Tor_Browser",
incoming_domain_id: 3>,
#<IncomingReferer:0x0000561cc08b2bc0
id: 11754,
path: "/wiki/Tor_Browser/Advanced_Users",
incoming_domain_id: 113>,
<page break> --- 按回车键继续(按 q<enter> 退出) --- <page break>
#<IncomingReferer:0x0000561cc08b2ad0
id: 12094,
path: "/wiki/Tor_Browser/Advanced_Users",
incoming_domain_id: 4560>,
#<IncomingReferer:0x0000561cc08b28f0
id: 12892,
path: "/wiki/Tor_Browser",
incoming_domain_id: 4559>,
#<IncomingReferer:0x0000561cc08b25f8
id: 13038,
path: "/wiki/Tor_Browser",
incoming_domain_id: 4560>]
[7] pry(main)>
[8] pry(main)>