이곳에 제시된 팁을 따라 업로드를 한 S3 버킷에서 다른 S3 버킷으로 마이그레이션했고, uploads:recover_from_tombstone과 posts:rebake의 도움으로 거의 모든 것이 다시 작동하고 있습니다 — 하지만 전부는 아닙니다.
저는 Ruby 개발자가 아니므로 디버깅 능력이 제한적입니다. 이제 uploads:recover를 실행하면 다음과 같은 출력이 많이 나옵니다:
Warning /t/foo/489/5 had an incorrect 4ff3ad05b76e1888161f41fd86da66efc16c290c should be 0b029ef3549e72dd5e3498abc7f979736d279a5e storing in custom field ‘rake uploads:fix_relative_upload_links’ can fix this
Warning /t/bar/498/4 had an incorrect 0649edb23196a8c84a9d71c04147bd8f0c96d0f7 should be f5b4e4bb3eedcd0fb83a06eecc4920f20c5e2bc4 storing in custom field ‘rake uploads:fix_relative_upload_links’ can fix this
Warning /t/bar/498/4 had an incorrect 0649edb23196a8c84a9d71c04147bd8f0c96d0f7 should be f5b4e4bb3eedcd0fb83a06eecc4920f20c5e2bc4 storing in custom field ‘rake uploads:fix_relative_upload_links’ can fix this
이 경고들은 업로드가 깨진 게시물에 해당하는 것 같습니다. 따라서 꽤 희망적인 신호로 보입니다. 그러나 fix_relative_upload_links를 실행해도 아무런 효과가 없는 것 같습니다.
rake uploads:fix_relative_upload_links --trace
** Invoke uploads:fix_relative_upload_links (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute uploads:fix_relative_upload_links
skipping missing upload in https://foo.com/t/bar/7/2 <img src="/uploads/default/35/f450f88541e87c52.png" width="198" height="70">
skipping missing upload in https://foo.com/t/bar/7/2 <img src="/uploads/default/36/0b73d33d9df37a66.png" width="120" height="43">
(스킵된 두 파일은 S3 이전의 오래된 업로드인 것 같습니다. 이전 경고가 생성된 S3 업로드에 대해서는 아무 출력도 없습니다.)
1년 전 유사한 문제가 보고된 사례가 있지만, 해결책을 포함한 유사한 보고서를 찾을 수 없습니다.
공식적으로 지원되지 않는 작업을 수행하고 있다는 점은 잘 알고 있지만, 조언을 주시면 감사하겠습니다.
마이그레이션 후 며칠 뒤에야 이 문제를 발견했습니다. 즉시 발견했다면 새로운 DB/S3 복원을 사용하여 다시 마이그레이션해 보았을 것입니다. 하지만 최근 게시물들을 잃고 싶지 않아서, 이제부터는 라이브 사이트 위에서 작업을 진행해야 합니다.
감사합니다.
수정: 또한 깨진 upload:// URL을 전체 URL로 변환하고 uploads 테이블의 레코드와 비교해 보았지만, 여전히 상황이 명확하지 않습니다.
작동하는 upload:// URL을 검사하면 유효한 URL을 가진 uploads 테이블 레코드에 매핑되지만, 깨진 URL을 검사해도… 역시 유효한 URL을 가진 레코드에 매핑됩니다. DB에 유효한 데이터가 있고, uploads 테이블에 할당된 URL에서 S3에 파일이 존재하는 것처럼 보입니다. 브라우저에서 S3 URL에 접근하는 데 문제가 없으므로, 왜 가져오기가 실패하는지 전혀 알 수 없습니다.