InfoGrab DocsInfoGrab Docs

업로드 마이그레이션 Rake 작업

요약

서로 다른 스토리지 유형 간에 업로드를 마이그레이션하는 Rake 태스크가 있습니다. GitLab 업로드에 대해 오브젝트 스토리지를 구성한 뒤에는 이 태스크로 기존 업로드를 로컬 스토리지에서 원격 스토리지로 마이그레이션합니다.

서로 다른 스토리지 유형 간에 업로드를 마이그레이션하는 Rake 태스크가 있습니다.

오브젝트 스토리지로 마이그레이션#

GitLab 업로드에 대해 오브젝트 스토리지를 구성한 뒤에는 이 태스크로 기존 업로드를 로컬 스토리지에서 원격 스토리지로 마이그레이션합니다.

모든 처리는 백그라운드 워커에서 이루어지며 다운타임이 필요하지 않습니다.

GitLab의 오브젝트 스토리지에 대한 자세한 내용을 참고합니다.

통합 Rake 태스크#

GitLab은 업로드된 모든 파일(예: 아바타, 로고, 첨부 파일, 파비콘)을 한 번에 오브젝트 스토리지로 마이그레이션하는 래퍼 Rake 태스크를 제공합니다. 래퍼 태스크는 각 범주에 해당하는 파일을 하나씩 마이그레이션하는 개별 Rake 태스크를 호출합니다.

이 개별 Rake 태스크는 다음 섹션에서 설명합니다.

로컬 스토리지의 모든 업로드를 오브젝트 스토리지로 마이그레이션하려면 다음 명령을 실행합니다.

gitlab-rake "gitlab:uploads:migrate:all"
sudo RAILS_ENV=production -u git -H bundle exec rake gitlab:uploads:migrate:all

선택 사항으로 PostgreSQL 콘솔을 사용해 진행 상황을 추적하고 모든 업로드가 성공적으로 마이그레이션되었는지 확인할 수 있습니다.

  • Linux 패키지 설치는 sudo gitlab-rails dbconsole --database main을 사용합니다.
  • 소스 컴파일 설치는 sudo -u git -H psql -d gitlabhq_production을 사용합니다.

아래에서 objectstg(store=2 인 경우)의 개수가 전체 아티팩트 수와 같은지 확인합니다.

gitlabhq_production=# SELECT count(*) AS total, sum(case when store = '1' then 1 else 0 end) AS filesystem, sum(case when store = '2' then 1 else 0 end) AS objectstg FROM uploads;

total | filesystem | objectstg
------+------------+-----------
   2409 |          0 |      2409

uploads 폴더의 디스크에 파일이 남아 있지 않은지 확인합니다.

sudo find /var/opt/gitlab/gitlab-rails/uploads -type f | grep -v tmp | wc -l

개별 Rake 태스크#

통합 Rake 태스크를 이미 실행했다면 이 개별 태스크는 실행할 필요가 없습니다.

Rake 태스크는 마이그레이션할 업로드를 찾기 위해 세 가지 파라미터를 사용합니다.

매개변수 유형 설명
uploader_class string 마이그레이션할 업로더의 유형.
model_class string 마이그레이션할 모델의 유형.
mount_point string/symbol 업로더가 마운트된 모델의 열 이름.
Note

이 파라미터는 주로 GitLab 내부 구조에 해당하므로 아래 태스크 목록을 참고하는 편이 낫습니다. 이 개별 태스크를 실행한 뒤에는 목록에 없는 유형의 업로드까지 마이그레이션하도록 통합 Rake 태스크를 실행할 것을 권장합니다.

이 태스크는 기본 배치 크기를 재정의할 수 있는 환경 변수도 받습니다.

변수 유형 설명
BATCH integer 배치 크기를 지정합니다. 기본값은 200입니다.

다음은 개별 업로드 유형에 대해 gitlab:uploads:migrate를 실행하는 방법입니다.

# gitlab-rake gitlab:uploads:migrate[uploader_class, model_class, mount_point]

# Avatars
gitlab-rake "gitlab:uploads:migrate[AvatarUploader, Project, :avatar]"
gitlab-rake "gitlab:uploads:migrate[AvatarUploader, Group, :avatar]"
gitlab-rake "gitlab:uploads:migrate[AvatarUploader, User, :avatar]"

# Attachments
gitlab-rake "gitlab:uploads:migrate[AttachmentUploader, Appearance, :logo]"
gitlab-rake "gitlab:uploads:migrate[AttachmentUploader, Appearance, :header_logo]"

# Favicon
gitlab-rake "gitlab:uploads:migrate[FaviconUploader, Appearance, :favicon]"

# Markdown
gitlab-rake "gitlab:uploads:migrate[FileUploader, Project]"
gitlab-rake "gitlab:uploads:migrate[PersonalFileUploader, Snippet]"
gitlab-rake "gitlab:uploads:migrate[NamespaceFileUploader, Snippet]"
gitlab-rake "gitlab:uploads:migrate[FileUploader, MergeRequest]"

# Design Management design thumbnails
gitlab-rake "gitlab:uploads:migrate[DesignManagement::DesignV432x230Uploader, DesignManagement::Action, :image_v432x230]"

모든 태스크에 RAILS_ENV=production을 사용합니다.

# sudo -u git -H bundle exec rake gitlab:uploads:migrate

# Avatars
sudo -u git -H bundle exec rake "gitlab:uploads:migrate[AvatarUploader, Project, :avatar]"
sudo -u git -H bundle exec rake "gitlab:uploads:migrate[AvatarUploader, Group, :avatar]"
sudo -u git -H bundle exec rake "gitlab:uploads:migrate[AvatarUploader, User, :avatar]"

# Attachments
sudo -u git -H bundle exec rake "gitlab:uploads:migrate[AttachmentUploader, Appearance, :logo]"
sudo -u git -H bundle exec rake "gitlab:uploads:migrate[AttachmentUploader, Appearance, :header_logo]"

# Favicon
sudo -u git -H bundle exec rake "gitlab:uploads:migrate[FaviconUploader, Appearance, :favicon]"

# Markdown
sudo -u git -H bundle exec rake "gitlab:uploads:migrate[FileUploader, Project]"
sudo -u git -H bundle exec rake "gitlab:uploads:migrate[PersonalFileUploader, Snippet]"
sudo -u git -H bundle exec rake "gitlab:uploads:migrate[NamespaceFileUploader, Snippet]"
sudo -u git -H bundle exec rake "gitlab:uploads:migrate[FileUploader, MergeRequest]"

# Design Management design thumbnails
sudo -u git -H bundle exec rake "gitlab:uploads:migrate[DesignManagement::DesignV432x230Uploader, DesignManagement::Action]"

로컬 스토리지로 마이그레이션#

어떤 이유로든 오브젝트 스토리지를 비활성화해야 한다면, 먼저 데이터를 오브젝트 스토리지에서 로컬 스토리지로 다시 마이그레이션해야 합니다.

Warning

마이그레이션 중 오브젝트 스토리지에 새 파일이 생성되지 않도록 장시간의 다운타임이 필요합니다. 구성 변경에 필요한 짧은 다운타임만으로 오브젝트 스토리지에서 로컬 파일로 마이그레이션할 수 있게 하는 구성 설정은 이 이슈에서 추적하고 있습니다.

또한 Cloud Native GitLab에서는 로컬 스토리지가 임시 저장소이고 모든 GitLab Rails 애플리케이션 컨테이너와 공유되지 않으므로 데이터를 로컬 스토리지로 마이그레이션하는 방식은 일반적으로 안전하지 않습니다.

통합 Rake 태스크#

GitLab은 업로드된 모든 파일(예: 아바타, 로고, 첨부 파일, 파비콘)을 한 번에 로컬 스토리지로 마이그레이션하는 래퍼 Rake 태스크를 제공합니다. 래퍼 태스크는 각 범주에 해당하는 파일을 하나씩 마이그레이션하는 개별 Rake 태스크를 호출합니다.

이 Rake 태스크에 대한 자세한 내용은 개별 Rake 태스크를 참고합니다. 이 경우 태스크 이름은 gitlab:uploads:migrate_to_local 입니다.

오브젝트 스토리지에서 로컬 스토리지로 업로드를 마이그레이션하려면 다음 명령을 실행합니다.

gitlab-rake "gitlab:uploads:migrate_to_local:all"
sudo RAILS_ENV=production -u git -H bundle exec rake gitlab:uploads:migrate_to_local:all

Rake 태스크를 실행한 뒤에는 오브젝트 스토리지 구성 안내에 설명된 변경 사항을 되돌려 오브젝트 스토리지를 비활성화할 수 있습니다.

업로드 마이그레이션 Rake 작업

GitLab v19.5
Tier: Free, Premium, Ultimate
Offering: GitLab Self-Managed
원문 보기

요약

서로 다른 스토리지 유형 간에 업로드를 마이그레이션하는 Rake 태스크가 있습니다. GitLab 업로드에 대해 오브젝트 스토리지를 구성한 뒤에는 이 태스크로 기존 업로드를 로컬 스토리지에서 원격 스토리지로 마이그레이션합니다.

서로 다른 스토리지 유형 간에 업로드를 마이그레이션하는 Rake 태스크가 있습니다.

오브젝트 스토리지로 마이그레이션#

GitLab 업로드에 대해 오브젝트 스토리지를 구성한 뒤에는 이 태스크로 기존 업로드를 로컬 스토리지에서 원격 스토리지로 마이그레이션합니다.

모든 처리는 백그라운드 워커에서 이루어지며 다운타임이 필요하지 않습니다.

GitLab의 오브젝트 스토리지에 대한 자세한 내용을 참고합니다.

통합 Rake 태스크#

GitLab은 업로드된 모든 파일(예: 아바타, 로고, 첨부 파일, 파비콘)을 한 번에 오브젝트 스토리지로 마이그레이션하는 래퍼 Rake 태스크를 제공합니다. 래퍼 태스크는 각 범주에 해당하는 파일을 하나씩 마이그레이션하는 개별 Rake 태스크를 호출합니다.

이 개별 Rake 태스크는 다음 섹션에서 설명합니다.

로컬 스토리지의 모든 업로드를 오브젝트 스토리지로 마이그레이션하려면 다음 명령을 실행합니다.

gitlab-rake "gitlab:uploads:migrate:all"
sudo RAILS_ENV=production -u git -H bundle exec rake gitlab:uploads:migrate:all

선택 사항으로 PostgreSQL 콘솔을 사용해 진행 상황을 추적하고 모든 업로드가 성공적으로 마이그레이션되었는지 확인할 수 있습니다.

  • Linux 패키지 설치는 sudo gitlab-rails dbconsole --database main을 사용합니다.
  • 소스 컴파일 설치는 sudo -u git -H psql -d gitlabhq_production을 사용합니다.

아래에서 objectstg(store=2 인 경우)의 개수가 전체 아티팩트 수와 같은지 확인합니다.

gitlabhq_production=# SELECT count(*) AS total, sum(case when store = '1' then 1 else 0 end) AS filesystem, sum(case when store = '2' then 1 else 0 end) AS objectstg FROM uploads;

total | filesystem | objectstg
------+------------+-----------
   2409 |          0 |      2409

uploads 폴더의 디스크에 파일이 남아 있지 않은지 확인합니다.

sudo find /var/opt/gitlab/gitlab-rails/uploads -type f | grep -v tmp | wc -l

개별 Rake 태스크#

통합 Rake 태스크를 이미 실행했다면 이 개별 태스크는 실행할 필요가 없습니다.

Rake 태스크는 마이그레이션할 업로드를 찾기 위해 세 가지 파라미터를 사용합니다.

매개변수 유형 설명
uploader_class string 마이그레이션할 업로더의 유형.
model_class string 마이그레이션할 모델의 유형.
mount_point string/symbol 업로더가 마운트된 모델의 열 이름.
Note

이 파라미터는 주로 GitLab 내부 구조에 해당하므로 아래 태스크 목록을 참고하는 편이 낫습니다. 이 개별 태스크를 실행한 뒤에는 목록에 없는 유형의 업로드까지 마이그레이션하도록 통합 Rake 태스크를 실행할 것을 권장합니다.

이 태스크는 기본 배치 크기를 재정의할 수 있는 환경 변수도 받습니다.

변수 유형 설명
BATCH integer 배치 크기를 지정합니다. 기본값은 200입니다.

다음은 개별 업로드 유형에 대해 gitlab:uploads:migrate를 실행하는 방법입니다.

# gitlab-rake gitlab:uploads:migrate[uploader_class, model_class, mount_point]

# Avatars
gitlab-rake "gitlab:uploads:migrate[AvatarUploader, Project, :avatar]"
gitlab-rake "gitlab:uploads:migrate[AvatarUploader, Group, :avatar]"
gitlab-rake "gitlab:uploads:migrate[AvatarUploader, User, :avatar]"

# Attachments
gitlab-rake "gitlab:uploads:migrate[AttachmentUploader, Appearance, :logo]"
gitlab-rake "gitlab:uploads:migrate[AttachmentUploader, Appearance, :header_logo]"

# Favicon
gitlab-rake "gitlab:uploads:migrate[FaviconUploader, Appearance, :favicon]"

# Markdown
gitlab-rake "gitlab:uploads:migrate[FileUploader, Project]"
gitlab-rake "gitlab:uploads:migrate[PersonalFileUploader, Snippet]"
gitlab-rake "gitlab:uploads:migrate[NamespaceFileUploader, Snippet]"
gitlab-rake "gitlab:uploads:migrate[FileUploader, MergeRequest]"

# Design Management design thumbnails
gitlab-rake "gitlab:uploads:migrate[DesignManagement::DesignV432x230Uploader, DesignManagement::Action, :image_v432x230]"

모든 태스크에 RAILS_ENV=production을 사용합니다.

# sudo -u git -H bundle exec rake gitlab:uploads:migrate

# Avatars
sudo -u git -H bundle exec rake "gitlab:uploads:migrate[AvatarUploader, Project, :avatar]"
sudo -u git -H bundle exec rake "gitlab:uploads:migrate[AvatarUploader, Group, :avatar]"
sudo -u git -H bundle exec rake "gitlab:uploads:migrate[AvatarUploader, User, :avatar]"

# Attachments
sudo -u git -H bundle exec rake "gitlab:uploads:migrate[AttachmentUploader, Appearance, :logo]"
sudo -u git -H bundle exec rake "gitlab:uploads:migrate[AttachmentUploader, Appearance, :header_logo]"

# Favicon
sudo -u git -H bundle exec rake "gitlab:uploads:migrate[FaviconUploader, Appearance, :favicon]"

# Markdown
sudo -u git -H bundle exec rake "gitlab:uploads:migrate[FileUploader, Project]"
sudo -u git -H bundle exec rake "gitlab:uploads:migrate[PersonalFileUploader, Snippet]"
sudo -u git -H bundle exec rake "gitlab:uploads:migrate[NamespaceFileUploader, Snippet]"
sudo -u git -H bundle exec rake "gitlab:uploads:migrate[FileUploader, MergeRequest]"

# Design Management design thumbnails
sudo -u git -H bundle exec rake "gitlab:uploads:migrate[DesignManagement::DesignV432x230Uploader, DesignManagement::Action]"

로컬 스토리지로 마이그레이션#

어떤 이유로든 오브젝트 스토리지를 비활성화해야 한다면, 먼저 데이터를 오브젝트 스토리지에서 로컬 스토리지로 다시 마이그레이션해야 합니다.

Warning

마이그레이션 중 오브젝트 스토리지에 새 파일이 생성되지 않도록 장시간의 다운타임이 필요합니다. 구성 변경에 필요한 짧은 다운타임만으로 오브젝트 스토리지에서 로컬 파일로 마이그레이션할 수 있게 하는 구성 설정은 이 이슈에서 추적하고 있습니다.

또한 Cloud Native GitLab에서는 로컬 스토리지가 임시 저장소이고 모든 GitLab Rails 애플리케이션 컨테이너와 공유되지 않으므로 데이터를 로컬 스토리지로 마이그레이션하는 방식은 일반적으로 안전하지 않습니다.

통합 Rake 태스크#

GitLab은 업로드된 모든 파일(예: 아바타, 로고, 첨부 파일, 파비콘)을 한 번에 로컬 스토리지로 마이그레이션하는 래퍼 Rake 태스크를 제공합니다. 래퍼 태스크는 각 범주에 해당하는 파일을 하나씩 마이그레이션하는 개별 Rake 태스크를 호출합니다.

이 Rake 태스크에 대한 자세한 내용은 개별 Rake 태스크를 참고합니다. 이 경우 태스크 이름은 gitlab:uploads:migrate_to_local 입니다.

오브젝트 스토리지에서 로컬 스토리지로 업로드를 마이그레이션하려면 다음 명령을 실행합니다.

gitlab-rake "gitlab:uploads:migrate_to_local:all"
sudo RAILS_ENV=production -u git -H bundle exec rake gitlab:uploads:migrate_to_local:all

Rake 태스크를 실행한 뒤에는 오브젝트 스토리지 구성 안내에 설명된 변경 사항을 되돌려 오브젝트 스토리지를 비활성화할 수 있습니다.