포럼 업데이트 중 멈춤 및 PG 마이그레이션 문제

여러 가지 방법을 시도해 보았지만 실패해서 여기에 게시합니다. 업그레이드에서 막혀 버렸네요.

  • 몇 달 만에 포럼을 업데이트하고 있었습니다. 평소처럼 백업을 실행하고 다운로드했습니다.
  • 그런데 이 업데이트 과정에서 PG 13에서 15로의 마이그레이션이 수행되는 것 같습니다.
    업데이트가 실패할 때까지 모든 것이 문제없이 작동했으며, 디스크 공간 부족으로 인해 작업이 중단되었습니다.
  • Digitalocean 드롭렛에 접속하여 이를 중지하고, 디스크를 확장한 뒤 다시 시작했습니다.
  • 디스크 공간을 확보하기 위해 몇 가지 일반적인 명령을 실행했습니다(오래된 로그 삭제, ./launcher cleanup 등).

그리고 재구축을 시작했는데, 첫 번째 벽에 부딪혔습니다:

root@discourse-ubuntu-s-2vcpu-4gb-fra1-01:/var/discourse# ./launcher rebuild app
WARNING: Docker version 20.10.1 deprecated, recommend upgrade to 24.0.7 or newer.
x86_64 arch detected.
WARNING: containers/app.yml file is world-readable. You can secure this file by running: chmod o-rwx containers/app.yml
Ensuring launcher is up to date
Fetching origin
Launcher is up-to-date
2.0.20250226-0128: Pulling from discourse/base
Digest: sha256:6f18aa2cd22bba0deb91d69194e577d4f96130ad555ae8ec646a8792cbfe37db
Status: Image is up to date for discourse/base:2.0.20250226-0128
docker.io/discourse/base:2.0.20250226-0128
/usr/local/lib/ruby/gems/3.3.0/gems/pups-1.2.1/lib/pups.rb
/usr/local/bin/pups --stdin
I, [2025-06-11T08:57:06.040908 #1]  INFO -- : Reading from stdin
I, [2025-06-11T08:57:06.055466 #1]  INFO -- : File > /etc/service/postgres/run  chmod: +x  chown:
I, [2025-06-11T08:57:06.059785 #1]  INFO -- : File > /etc/service/postgres/log/run  chmod: +x  chown:
I, [2025-06-11T08:57:06.064063 #1]  INFO -- : File > /etc/runit/3.d/99-postgres  chmod: +x  chown:
I, [2025-06-11T08:57:06.068330 #1]  INFO -- : File > /root/install_postgres  chmod: +x  chown:
I, [2025-06-11T08:57:06.072788 #1]  INFO -- : File > /root/upgrade_postgres  chmod: +x  chown:
I, [2025-06-11T08:57:06.073111 #1]  INFO -- : Replacing data_directory = '/var/lib/postgresql/15/main' with data_directory = '/shared/postgres_data' in /etc/postgresql/15/main/postgresql.conf
I, [2025-06-11T08:57:06.074045 #1]  INFO -- : Replacing (?-mix:#?listen_addresses *=.*) with listen_addresses = '*' in /etc/postgresql/15/main/postgresql.conf
I, [2025-06-11T08:57:06.074682 #1]  INFO -- : Replacing (?-mix:#?synchronous_commit *=.*) with synchronous_commit = $db_synchronous_commit in /etc/postgresql/15/main/postgresql.conf
I, [2025-06-11T08:57:06.075269 #1]  INFO -- : Replacing (?-mix:#?shared_buffers *=.*) with shared_buffers = $db_shared_buffers in /etc/postgresql/15/main/postgresql.conf
I, [2025-06-11T08:57:06.080274 #1]  INFO -- : Replacing (?-mix:#?work_mem *=.*) with work_mem = $db_work_mem in /etc/postgresql/15/main/postgresql.conf
I, [2025-06-11T08:57:06.081190 #1]  INFO -- : Replacing (?-mix:#?default_text_search_config *=.*) with default_text_search_config = '$db_default_text_search_config' in /etc/postgresql/15/main/postgresql.conf
I, [2025-06-11T08:57:06.081687 #1]  INFO -- : Replacing (?-mix:#?checkpoint_segments *=.*) with checkpoint_segments = $db_checkpoint_segments in /etc/postgresql/15/main/postgresql.conf
I, [2025-06-11T08:57:06.082397 #1]  INFO -- : Replacing (?-mix:#?logging_collector *=.*) with logging_collector = $db_logging_collector in /etc/postgresql/15/main/postgresql.conf
I, [2025-06-11T08:57:06.083025 #1]  INFO -- : Replacing (?-mix:#?log_min_duration_statement *=.*) with log_min_duration_statement = $db_log_min_duration_statement in /etc/postgresql/15/main/postgresql.conf
I, [2025-06-11T08:57:06.083657 #1]  INFO -- : Replacing (?-mix:^#local +replication +postgres +peer$) with local replication postgres  peer in /etc/postgresql/15/main/pg_hba.conf
I, [2025-06-11T08:57:06.083968 #1]  INFO -- : Replacing (?-mix:^host.*all.*all.*127.*$) with host all all 0.0.0.0/0 md5 in /etc/postgresql/15/main/pg_hba.conf
I, [2025-06-11T08:57:06.084391 #1]  INFO -- : Replacing (?-mix:^host.*all.*all.*::1\/128.*$) with host all all ::/0 md5 in /etc/postgresql/15/main/pg_hba.conf
I, [2025-06-11T08:57:06.084877 #1]  INFO -- : > if [ -f /root/install_postgres ]; then
  /root/install_postgres && rm -f /root/install_postgres
elif [ -e /shared/postgres_run/.s.PGSQL.5432 ]; then
  socat /dev/null UNIX-CONNECT:/shared/postgres_run/.s.PGSQL.5432 || exit 0 && echo postgres already running stop container ; exit 1
fi

failed to set locale!
[error] character map file `UTF-8' not found: No such file or directory
failed to set locale!
[error] default character map file `ANSI_X3.4-1968' not found: No such file or directory
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = "en_US.UTF-8",
	LC_ALL = "en_US.UTF-8",
	LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
popen failure: Cannot allocate memory
initdb: error: program "postgres" is needed by initdb but was not found in the same directory as "/usr/lib/postgresql/15/bin/initdb"
I, [2025-06-11T08:57:07.265267 #1]  INFO -- : Generating locales (this might take a while)...
  en_US.UTF-8... done
Generation complete.
Upgrading PostgreSQL from version 13 to 15

I, [2025-06-11T08:57:07.265539 #1]  INFO -- : > HOME=/var/lib/postgresql USER=postgres exec chpst -u postgres:postgres:ssl-cert -U postgres:postgres:ssl-cert /usr/lib/postgresql/15/bin/postmaster -D /etc/postgresql/15/main
I, [2025-06-11T08:57:07.267705 #1]  INFO -- : Terminating async processes
2025-06-11 08:57:07.283 UTC [50] FATAL:  database files are incompatible with server
2025-06-11 08:57:07.283 UTC [50] DETAIL:  The data directory was initialized by PostgreSQL version 13, which is not compatible with this version 15.12 (Debian 15.12-1.pgdg120+1).

구글 검색과 ChatGPT를 조금 이용해 로그를 이해한 결과, PG 13으로 돌아가 포럼을 복원하는 데 집중하기로 결정했습니다. 이를 위해 yml 템플릿을 편집하여 "templates/postgres.13.template.yml"을 강제 적용했습니다.

그런데 두 번째 벽에 부딪혔습니다:


root@discourse-ubuntu-s-2vcpu-4gb-fra1-01:/var/discourse# ./launcher rebuild app
WARNING: Docker version 20.10.1 deprecated, recommend upgrade to 24.0.7 or newer.
x86_64 arch detected.
WARNING: containers/app.yml file is world-readable. You can secure this file by running: chmod o-rwx containers/app.yml
Ensuring launcher is up to date
Fetching origin
Launcher is up-to-date
2.0.20250226-0128: Pulling from discourse/base
Digest: sha256:6f18aa2cd22bba0deb91d69194e577d4f96130ad555ae8ec646a8792cbfe37db
Status: Image is up to date for discourse/base:2.0.20250226-0128
docker.io/discourse/base:2.0.20250226-0128
/usr/local/lib/ruby/gems/3.3.0/gems/pups-1.2.1/lib/pups.rb
/usr/local/bin/pups --stdin
I, [2025-06-11T09:07:40.418731 #1]  INFO -- : Reading from stdin
I, [2025-06-11T09:07:40.428644 #1]  INFO -- : > DEBIAN_FRONTEND=noninteractive apt-get purge -y postgresql-15 postgresql-client-15 postgresql-contrib-15 postgresql-15-pgvector
E: Problem executing scripts DPkg::Post-Invoke 'rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true'
E: Sub-process returned an error code
I, [2025-06-11T09:07:41.892381 #1]  INFO -- : Reading package lists...
Building dependency tree...
Reading state information...
The following packages were automatically installed and are no longer required:
  libcommon-sense-perl libio-pty-perl libipc-run-perl libjson-perl
  libjson-xs-perl libllvm19 libtypes-serialiser-perl libz3-4
  postgresql-client-common postgresql-common postgresql-common-dev ssl-cert
Use 'apt autoremove' to remove them.
The following packages will be REMOVED:
  postgresql-15* postgresql-15-pgvector* postgresql-client-15*
0 upgraded, 0 newly installed, 3 to remove and 0 not upgraded.
After this operation, 60.9 MB disk space will be freed.
(Reading database ... 33951 files and directories currently installed.)
Removing postgresql-15-pgvector (0.8.0-1.pgdg120+1) ...
Removing postgresql-15 (15.12-1.pgdg120+1) ...
invoke-rc.d: could not determine current runlevel
update-alternatives: warning: forcing reinstallation of alternative /usr/share/postgresql/15/man/man1/psql.1.gz because link group psql.1.gz is broken
Removing postgresql-client-15 (15.12-1.pgdg120+1) ...
Processing triggers for postgresql-common (274.pgdg120+1) ...
Building PostgreSQL dictionaries from installed myspell/hunspell packages...
Removing obsolete dictionary files:
(Reading database ... 31913 files and directories currently installed.)
Purging configuration files for postgresql-15 (15.12-1.pgdg120+1) ...
Dropping cluster main...



FAILED
--------------------
Pups::ExecError: DEBIAN_FRONTEND=noninteractive apt-get purge -y postgresql-15 postgresql-client-15 postgresql-contrib-15 postgresql-15-pgvector failed with return #<Process::Status: pid 7 exit 100>
Location of failure: /usr/local/lib/ruby/gems/3.3.0/gems/pups-1.2.1/lib/pups/exec_command.rb:132:in `spawn'
exec failed with the params "DEBIAN_FRONTEND=noninteractive apt-get purge -y postgresql-15 postgresql-client-15 postgresql-contrib-15 postgresql-15-pgvector"
bootstrap failed with exit code 100
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one.
./discourse-doctor may help diagnose the problem.
59b3543b15880ef0391688f71c9cb827ef791dbc37f1e4f896d9d7a31841c83b

이제 막혀버렸고 어떻게 진행해야 할지 모르겠습니다. 추천해 주신다면 정말 감사하겠습니다. 포럼이 매우 크고, 해고당하기 전에 몇 시간 안에 다시 온라인으로 복원해야 하는 상황이라요 :frowning:

업데이트:
여전히 여러 가지를 시도하고 있습니다. 이 시점에서는 PG13을 지원하는 빌드로 돌아가서 백업을 복원하고 싶을 뿐인데, 여전히 그 시도가 막혀 있습니다.

업그레이드 전의 커밋 해시는 v3.3.0.beta6 +294 였으며, YML을 통해 해당 버전을 다시 빌드해 보려 하고 있지만 빌드 시 여전히 다음과 같은 메시지가 나타납니다:

root@discourse-ubuntu-s-2vcpu-4gb-fra1-01:/var/discourse# ./launcher rebuild app
WARNING: Docker version 20.10.1 deprecated, recommend upgrade to 24.0.7 or newer.
x86_64 arch detected.

WARNING: We are about to start downloading the Discourse base image
This process may take anywhere between a few minutes to an hour, depending on your network speed

Please be patient

2.0.20250226-0128: Pulling from discourse/base
af302e5c37e9: Pull complete
ed49ab5c933d: Pull complete
4d13d450f300: Pull complete
a67afd5cca97: Pull complete
d22a5b6769a6: Pull complete
83c133b53b22: Pull complete
fec147508f0c: Pull complete
21850d8b3ba1: Pull complete
02e250b6bcc4: Pull complete
71ba5ea7da00: Pull complete
ddcfbf6d2647: Pull complete
9c3e54d34536: Pull complete
29ce98d2d62d: Pull complete
4c9694455fd5: Pull complete
58a8ebcc6563: Pull complete
9c8966f1f999: Pull complete
b3dde96c4217: Pull complete
f934de9e2e8d: Pull complete
834e25f513a1: Pull complete
85d3cf606a95: Pull complete
94331a6982ee: Pull complete
14936beb0e9f: Pull complete
3ef05b122d47: Pull complete
6c2dff13a1e7: Pull complete
7682543ad38b: Pull complete
f16f8d5c5a04: Pull complete
06d7037d56ef: Pull complete
bc6c17ae1969: Pull complete
d19f089ead0e: Pull complete
Digest: sha256:6f18aa2cd22bba0deb91d69194e577d4f96130ad555ae8ec646a8792cbfe37db
Status: Downloaded newer image for discourse/base:2.0.20250226-0128
docker.io/discourse/base:2.0.20250226-0128
WARNING: containers/app.yml file is world-readable. You can secure this file by running: chmod o-rwx containers/app.yml
Ensuring launcher is up to date
Fetching origin
Launcher is up-to-date
2.0.20250226-0128: Pulling from discourse/base
Digest: sha256:6f18aa2cd22bba0deb91d69194e577d4f96130ad555ae8ec646a8792cbfe37db
Status: Image is up to date for discourse/base:2.0.20250226-0128
docker.io/discourse/base:2.0.20250226-0128
/usr/local/lib/ruby/gems/3.3.0/gems/pups-1.2.1/lib/pups.rb
/usr/local/bin/pups --stdin
I, [2025-06-11T09:54:52.350929 #1]  INFO -- : Reading from stdin
I, [2025-06-11T09:54:52.357807 #1]  INFO -- : > DEBIAN_FRONTEND=noninteractive apt-get purge -y postgresql-15 postgresql-client-15 postgresql-contrib-15 postgresql-15-pgvector
E: Problem executing scripts DPkg::Post-Invoke 'rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true'
E: Sub-process returned an error code
I, [2025-06-11T09:54:53.837808 #1]  INFO -- : Reading package lists...
Building dependency tree...
Reading state information...
The following packages were automatically installed and are no longer required:
  libcommon-sense-perl libio-pty-perl libipc-run-perl libjson-perl
  libjson-xs-perl libllvm19 libtypes-serialiser-perl libz3-4
  postgresql-client-common postgresql-common postgresql-common-dev ssl-cert
Use 'apt autoremove' to remove them.
The following packages will be REMOVED:
  postgresql-15* postgresql-15-pgvector* postgresql-client-15*
0 upgraded, 0 newly installed, 3 to remove and 0 not upgraded.
After this operation, 60.9 MB disk space will be freed.
(Reading database ... 33951 files and directories currently installed.)
Removing postgresql-15-pgvector (0.8.0-1.pgdg120+1) ...
Removing postgresql-15 (15.12-1.pgdg120+1) ...
invoke-rc.d: could not determine current runlevel
update-alternatives: warning: forcing reinstallation of alternative /usr/share/postgresql/15/man/man1/psql.1.gz because link group psql.1.gz is broken
Removing postgresql-client-15 (15.12-1.pgdg120+1) ...
Processing triggers for postgresql-common (274.pgdg120+1) ...
Building PostgreSQL dictionaries from installed myspell/hunspell packages...
Removing obsolete dictionary files:
(Reading database ... 31913 files and directories currently installed.)
Purging configuration files for postgresql-15 (15.12-1.pgdg120+1) ...
Dropping cluster main...



FAILED
--------------------
Pups::ExecError: DEBIAN_FRONTEND=noninteractive apt-get purge -y postgresql-15 postgresql-client-15 postgresql-contrib-15 postgresql-15-pgvector failed with return #<Process::Status: pid 7 exit 100>
Location of failure: /usr/local/lib/ruby/gems/3.3.0/gems/pups-1.2.1/lib/pups/exec_command.rb:132:in `spawn'
exec failed with the params "DEBIAN_FRONTEND=noninteractive apt-get purge -y postgresql-15 postgresql-client-15 postgresql-contrib-15 postgresql-15-pgvector"
bootstrap failed with exit code 100
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one.
./discourse-doctor may help diagnose the problem.
a609309cf458b146e5650d21103bf084e9bf66843e46e627827f50b6f8c03376

말씀하신 대로 백업을 해두셨다면, 가장 쉬운 방법은 새로운 드롭렛을 생성한 후 rsync를 사용하여 Discourse 사이트를 다른 VPS로 이전하기 가이드를 따르는 것입니다(단, 데이터베이스 파일은 복사하지 마세요). 그런 다음 백업을 복원하시면 됩니다.

하이

제이! 답변해 주셔서 정말 감사합니다. 방금 작업을 시작했는데, 드롭렛이 현재 설정 중입니다.

간단한 질문이 있습니다. 업데이트를 시작하기 전에 백업 파일을 다운로드했는데, 해당 파일은 forumname-2025-06-11-060249-v20240807024301.tar.gz (압축 4.6GB)입니다. 포럼 버전은 PG13과 함께 v3.3.0.beta6 +294였습니다.

새로운 드롭렛을 초기화할 때 app.yml에서 이 버전을 강제 지정할 계획입니다. 예를 들어 다음과 같이요:

## this is the all-in-one, standalone Discourse Docker container template
##
## After making changes to this file, you MUST rebuild
## /var/discourse/launcher rebuild app
##
## BE *VERY* CAREFUL WHEN EDITING!
## YAML FILES ARE SUPER SUPER SENSITIVE TO MISTAKES IN WHITESPACE OR ALIGNMENT!
## visit http://www.yamllint.com/ to validate this file as needed

templates:
  - "templates/postgres.template.yml"
  - "templates/redis.template.yml"
  - "templates/web.template.yml"
  - "templates/web.ratelimited.template.yml"
## Uncomment these two lines if you wish to add Lets Encrypt (https)
  - "templates/web.ssl.template.yml"
  - "templates/web.letsencrypt.ssl.template.yml"

## which TCP/IP ports should this container expose?
## If you want Discourse to share a port with another webserver like Apache or nginx,
## see https://meta.discourse.org/t/17247 for details
expose:
  - "80:80"   # http
  - "443:443" # https

params:
  db_default_text_search_config: "pg_catalog.english"

  ## Set db_shared_buffers to a max of 25% of the total memory.
  ## will be set automatically by bootstrap based on detected RAM, or you can override
  db_shared_buffers: "1024MB"

  ## can improve sorting performance, but adds memory usage per-connection
  #db_work_mem: "40MB"

  ## Which Git revision should this container use? (default: tests-passed)
  version: v3.3.0.beta6

그리고 새 포럼이 정상적으로 작동하기 시작하면, 거기서 백업을 가져오려고 합니다.

이렇게 하면 될까요? 아니면 중요한 매개변수나 단계를 놓치고 있는 건가요?

이것으로 끝입니다.

참고: 명령줄에서 백업 복원하기

Jay, 답변해 주셔서 다시 한번 감사합니다. 이 악몽 같은 상황을 헤쳐 나가는 데 시간을 내어 도와주신 것에 진심으로 감사드립니다.

저는 그렇게 시도하고 있습니다(YML에서 버전을 강제 지정하는 방식)만, discourse_docker가 아직 이 변경 사항에 대해 잘 반응하지 않는 것 같습니다:

FAILED
--------------------
Pups::ExecError: grep -q 'outlets/before-server' /etc/nginx/conf.d/discourse.conf || ( >&2 echo 'The "before-server" Nginx outlet is missing. This version of discourse_docker is not compatible with the chosen Discourse version.' ; exit 1 ) failed with return #<Process::Status: pid 2788 exit 1>
Location of failure: /usr/local/lib/ruby/gems/3.3.0/gems/pups-1.2.1/lib/pups/exec_command.rb:132:in spawn'
exec failed with the params {"cmd"=>["cp $home/config/nginx.sample.conf /etc/nginx/conf.d/discourse.conf", "rm /etc/nginx/sites-enabled/default", "mkdir -p /var/nginx/cache", "grep -q 'outlets/before-server' /etc/nginx/conf.d/discourse.conf || ( >&2 echo 'The \"before-server\" Nginx outlet is missing. This version of discourse_docker is not compatible with the chosen Discourse version.' ; exit 1 )", "grep -q 'outlets/server' /etc/nginx/conf.d/discourse.conf || ( >&2 echo 'The \"server\" Nginx outlet is missing. This version of discourse_docker is not compatible with the chosen Discourse version.' ; exit 1 )", "grep -q 'outlets/discourse' /etc/nginx/conf.d/discourse.conf || ( >&2 echo 'The \"discourse\" Nginx outlet is missing. This version of discourse_docker is not compatible with the chosen Discourse version.' ; exit 1 )", "mkdir -p /etc/nginx/conf.d/outlets/before-server", "touch /etc/nginx/conf.d/outlets/before-server/20-redirect-http-to-https.conf", "touch /etc/nginx/conf.d/outlets/before-server/30-ratelimited.conf", "mkdir -p /etc/nginx/conf.d/outlets/server", "touch /etc/nginx/conf.d/outlets/server/10-http.conf", "touch /etc/nginx/conf.d/outlets/server/20-https.conf", "touch /etc/nginx/conf.d/outlets/server/30-offline-page.conf", "mkdir -p /etc/nginx/conf.d/outlets/discourse", "touch /etc/nginx/conf.d/outlets/discourse/20-https.conf", "touch /etc/nginx/conf.d/outlets/discourse/30-ratelimited.conf"]}
bootstrap failed with exit code 1
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one.
./discourse-doctor may help diagnose the problem.
d511b0ec31ac912c99c682611c35bbb446dde1488e1762aa07ccd24690c63164



2/2


업데이트하기 전에 혹시 모르도록 현재 버전의 스크린샷을 찍어 두었습니다. discourse_docker를 호환되는 이전 버전으로 강제 지정할 수 있는 방법이 있을까요?

구글과 여기 메타에서 검색해 보고 있지만, 아직 어떻게 해야 하는지에 대한 정보를 찾지 못했습니다.

그렇게 하지 마세요.

모든 것의 최신 버전을 정상적으로 설치하고 데이터베이스를 복구하세요.

알겠습니다. 지금 바로 시도해 보겠습니다.

다만, 간단한 질문이 있습니다. 백업이 PG13을 사용하던 구버전 Discourse에서 가져온 것이라면, PG15가 적용된 최신 버전의 Discourse에 이 백업을 가져오는 과정에서 문제가 발생합니까?

@pfaffman 죄송합니다. 이전 메시지는 문제가 해결된 줄 알고 작성했는데, 그 뒤에 상황이 반전되었습니다.

오래된 데이터를 가져오는 작업이 한참 진행되던 중, 포럼이 다시 온라인에 접속되어 모든 게시글 등이 목록에 표시되는 것을 확인했습니다.

터미널에는 다음과 같은 로그가 출력되었습니다:

[...]

-- execute("DELETE FROM site_settings WHERE name='warn_reviving_old_topic_age'")
   -> 0.0002s
== 20250609115711 RemoveComposerTipsSiteSettings: migrated (0.0012s) ==========

Reconnecting to the database...
Reloading site settings...
Disabling outgoing emails for non-staff users...
Disabling readonly mode...
Clearing category cache...
Reloading translations...
Remapping uploads...
Restoring uploads, this may take a while...
Migrating uploads to S3 for 'default'...
Uploading files to S3...
 - Listing local files
 => 5 files
 - Listing S3 files
............................................................................................................................................................................ => 171490 files
 - Syncing files to S3
.....
Updating the URLs in the database...

잠시 동안 그 상태로 있었는데, 제 터미널 연결 문제인 줄 알았습니다. 그러나 몇 분 후, 프로세스가 실패로 끝나며 계속 진행되었습니다:

490 files
 - Syncing files to S3
.....
Updating the URLs in the database...
Removing old optimized images...
Flagging all posts containing lightboxes for rebake...
76198 posts were flagged for a rebake
EXCEPTION: 903 posts are not remapped to new S3 upload URL. S3 migration failed for db 'default'.
/var/www/discourse/lib/file_store/to_s3_migration.rb:132:in `raise_or_log'
/var/www/discourse/lib/file_store/to_s3_migration.rb:81:in `migration_successful?'
/var/www/discourse/lib/file_store/to_s3_migration.rb:383:in `migrate_to_s3'
/var/www/discourse/lib/file_store/to_s3_migration.rb:59:in `migrate'
/var/www/discourse/lib/file_store/s3_store.rb:354:in `copy_from'
/var/www/discourse/lib/backup_restore/uploads_restorer.rb:69:in `restore_uploads'
/var/www/discourse/lib/backup_restore/uploads_restorer.rb:49:in `restore'
/var/www/discourse/lib/backup_restore/restorer.rb:167:in `restore_uploads'
/var/www/discourse/lib/backup_restore/restorer.rb:71:in `run'
script/discourse:191:in `restore'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/thor-1.3.2/lib/thor/command.rb:28:in `run'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/thor-1.3.2/lib/thor/invocation.rb:127:in `invoke_command'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/thor-1.3.2/lib/thor.rb:538:in `dispatch'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/thor-1.3.2/lib/thor/base.rb:584:in `start'
script/discourse:345:in `<top (required)>'
/usr/local/lib/ruby/gems/3.3.0/gems/bundler-2.6.4/lib/bundler/cli/exec.rb:59:in `load'
/usr/local/lib/ruby/gems/3.3.0/gems/bundler-2.6.4/lib/bundler/cli/exec.rb:59:in `kernel_load'
/usr/local/lib/ruby/gems/3.3.0/gems/bundler-2.6.4/lib/bundler/cli/exec.rb:23:in `run'
/usr/local/lib/ruby/gems/3.3.0/gems/bundler-2.6.4/lib/bundler/cli.rb:452:in `exec'
/usr/local/lib/ruby/gems/3.3.0/gems/bundler-2.6.4/lib/bundler/vendor/thor/lib/thor/command.rb:28:in `run'
/usr/local/lib/ruby/gems/3.3.0/gems/bundler-2.6.4/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/usr/local/lib/ruby/gems/3.3.0/gems/bundler-2.6.4/lib/bundler/vendor/thor/lib/thor.rb:538:in `dispatch'
/usr/local/lib/ruby/gems/3.3.0/gems/bundler-2.6.4/lib/bundler/cli.rb:35:in `dispatch'
/usr/local/lib/ruby/gems/3.3.0/gems/bundler-2.6.4/lib/bundler/vendor/thor/lib/thor/base.rb:584:in `start'
/usr/local/lib/ruby/gems/3.3.0/gems/bundler-2.6.4/lib/bundler/cli.rb:29:in `start'
/usr/local/lib/ruby/gems/3.3.0/gems/bundler-2.6.4/exe/bundle:28:in `block in <top (required)>'
/usr/local/lib/ruby/gems/3.3.0/gems/bundler-2.6.4/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
/usr/local/lib/ruby/gems/3.3.0/gems/bundler-2.6.4/exe/bundle:20:in `<top (required)>'
/usr/local/bin/bundle:25:in `load'
/usr/local/bin/bundle:25: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/2025-06-11-121115' directory...
Unpausing sidekiq...
Marking restore as finished...
Notifying 'system' of the end of the restore...
Finished!
[FAILED]
Restore done.

갑자기 "복원"되어 온라인 상태가 된 포럼에서 모든 게시글이 사라지고, 단 몇 개의 주제만 남아있는 상태가 되었습니다.

로그에 "76198 posts were flagged for a rebake"라고 나와서, 이제 재처리(rebake)가 필요한 상태인 것 같다고 생각했습니다. 그래서 Sidekiq를 확인해 보았지만, 처리 대기 중인 작업이 아무것도 없었습니다 :frowning:

업데이트:

Rails 콘솔에 로그인해 보니, 가져오기로 예정된 모든 게시물이 아니라 10개뿐인 것으로 보입니다. :thinking:

/var/www/discourse# rails c
Loading production environment (Rails 7.2.2.1)
discourse(prod)> Post.count
=> 10
discourse(prod)> Post.where(“baked_version IS NULL”).count
=> 0

아쉬운 일이네요. 같은 호스트네임을 사용 중인가요? (아마도 그렇겠죠?)

이것이 지금 당신의 문제입니다.

S3를 데이터베이스에서 설정했나요, 아니면 yml 파일에서 설정했나요? 전자는 맞을 것 같습니다. 가장 쉬운 방법은 데이터베이스만 복구하는 것이지만, 설명하기가 어렵습니다 (sql 파일을 추출한 뒤 tar.gz 파일과 동일한 이름으로 명명해야 하므로).

아래와 같이 시도해 볼 수 있습니다.

discourse restore --pause <backup_filename>

이렇게 하면 S3 관련 복구를 시도하기 전에 일시 정지됩니다. 그리고 나서, 어떻게 해야 하는지 안다면 잘못된 업로드 문제를 수정할 수 있습니다.

Issues with restoring backup to discourse - #16 by gerhard 을 참고하세요.

다른 방법으로는 app.yml에서 DISCOURSE_USE_S3를 false로 설정하는 것입니다. S3 업로드를 사용하도록 하거나 S3 버킷을 지정하는 등 다른 S3 관련 설정도 변경해야 할 수 있습니다.

네, 그렇습니다. 하지만 말씀해 주시니 이제야 깨닫네요.

  • 이 포럼은 이제 10년이 되었습니다.
  • 예전에 S3를 잠시 사용하긴 했지만, 나중에 제거했기 때문에 S3 이미지를 포함한 게시글들은 꽤 오래된 것입니다.

이들을 식별하고 무시하거나 삭제하여 임포트가 마찰 없이 진행될 수 있는 방법이 있을까요?

또 다른 방법은 app.yml에서 DISCOURSE_USE_S3를 false로 설정하는 것입니다. S3 업로드 사용 또는 S3 버킷 관련 설정 등 다른 S3 항목들도 설정해야 할 수 있습니다.

결국 우리는 그 S3 파일이나 게시글에 관심이 없으므로, 이것도 시도해 볼 것입니다. 다만, 이를 무시하는 방법을 아직 정확히 모르겠습니다.

그걸 정말로 신경 쓰지 않는다면, 일시정지 기능을 사용해서 일시정지된 상태에서 다른 터미널을 열고 rails로 들어가서 다음과 같은 작업을 수행할 수 있습니다.

bad=Upload.where("url like '%the-s3-url%'")
bad.destroy_all

참고로, 아직 막막하고 급한데 예산이 있다면 이메일이나 PM으로 연락하거나 Marketplace 채널에서 질문할 수 있습니다.

처음부터 말해 주셨어야 했는데! 애초에 기꺼이 비용을 지불했을 거예요! 헤헤

이제 정상적으로 작동합니다.

여러 가지를 시도해 본 끝에 직관에 반하는 방법을 사용했는데, 지금은 잘 작동합니다:

  • 새 인스턴스에서 관리 패널을 통해 S3를 올바르게 설정했습니다.
  • 가져오기를 –pause 옵션과 함께 실행했지만, 두 번째 단계에서는 프로세스를 그냥 중지했습니다. 포럼이 작동하지 않거나 이미지 관련 문제가 생길 것으로 예상했지만, 포럼은 정상 작동하며 기존 이미지들도 문제없이 로드됩니다.

아직 테스트 중이라 나중에 깨진 부분이 발견될 수도 있지만, 12시간 동안 트러블슈팅을 한 결과 지금은 승리로 간주하겠습니다.

그것은 올바르지 않습니다. 업로드를 위한 S3 호환 객체 저장소 프로바이더 구성을 참조하세요. 해당 설정들은 모두 yml 파일에 포함되어야 합니다.