Uploads migrate Rake tasks

原文:https://docs.gitlab.com/ee/administration/raketasks/uploads/migrate.html

Uploads migrate Rake tasks

gitlab:uploads:migrate在不同的存储类型之间迁移上载.

Migrate to object storage

在为 GitLab 的上传配置对象存储后,使用此任务将现有的上传从本地存储迁移到远程存储.

阅读有关在 GitLab 上使用对象存储的更多信息.

注意:所有处理将在后台工作人员中完成, 无需停机 .

All-in-one Rake task

GitLab 提供了一个包装 Rake 任务,可将所有上载的文件(例如,头像,徽标,附件和网站图标)迁移到对象存储中. 包装器任务调用各个 Rake 任务来逐一迁移属于这些类别的文件.

这些单独的 Rake 任务将在下一部分中介绍.

要将所有上载从本地存储迁移到对象存储,请运行:

全部安装

  1. gitlab-rake "gitlab:uploads:migrate:all"

源安装

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

Individual Rake tasks

如果您已经运行了多合一 Rake 任务 ,则无需运行这些单独的任务.

Rake 任务使用三个参数来查找要迁移的上载:

Parameter Type Description
uploader_class string 要从中迁移的上传者的类型.
model_class string 要迁移的模型的类型.
mount_point string/symbol 上传器安装在其上的模型列的名称.

注意:这些参数主要是在 GitLab 结构的内部,您可能想参考下面的任务列表.

此任务还接受一个环境变量,您可以使用它来覆盖默认的批处理大小:

Variable Type Description
BATCH integer 指定批处理的大小. 默认为 200.

下面显示了如何针对各种类型的上传运行gitlab:uploads:migrate .

全部安装

  1. # gitlab-rake gitlab:uploads:migrate[uploader_class, model_class, mount_point]
  2. # Avatars
  3. gitlab-rake "gitlab:uploads:migrate[AvatarUploader, Project, :avatar]"
  4. gitlab-rake "gitlab:uploads:migrate[AvatarUploader, Group, :avatar]"
  5. gitlab-rake "gitlab:uploads:migrate[AvatarUploader, User, :avatar]"
  6. # Attachments
  7. gitlab-rake "gitlab:uploads:migrate[AttachmentUploader, Note, :attachment]"
  8. gitlab-rake "gitlab:uploads:migrate[AttachmentUploader, Appearance, :logo]"
  9. gitlab-rake "gitlab:uploads:migrate[AttachmentUploader, Appearance, :header_logo]"
  10. # Favicon
  11. gitlab-rake "gitlab:uploads:migrate[FaviconUploader, Appearance, :favicon]"
  12. # Markdown
  13. gitlab-rake "gitlab:uploads:migrate[FileUploader, Project]"
  14. gitlab-rake "gitlab:uploads:migrate[PersonalFileUploader, Snippet]"
  15. gitlab-rake "gitlab:uploads:migrate[NamespaceFileUploader, Snippet]"
  16. gitlab-rake "gitlab:uploads:migrate[FileUploader, MergeRequest]"
  17. # Design Management design thumbnails
  18. gitlab-rake "gitlab:uploads:migrate[DesignManagement::DesignV432x230Uploader, DesignManagement::Action, :image_v432x230]"

源安装

注意:为每个任务使用RAILS_ENV=production .

  1. # sudo -u git -H bundle exec rake gitlab:uploads:migrate
  2. # Avatars
  3. sudo -u git -H bundle exec rake "gitlab:uploads:migrate[AvatarUploader, Project, :avatar]"
  4. sudo -u git -H bundle exec rake "gitlab:uploads:migrate[AvatarUploader, Group, :avatar]"
  5. sudo -u git -H bundle exec rake "gitlab:uploads:migrate[AvatarUploader, User, :avatar]"
  6. # Attachments
  7. sudo -u git -H bundle exec rake "gitlab:uploads:migrate[AttachmentUploader, Note, :attachment]"
  8. sudo -u git -H bundle exec rake "gitlab:uploads:migrate[AttachmentUploader, Appearance, :logo]"
  9. sudo -u git -H bundle exec rake "gitlab:uploads:migrate[AttachmentUploader, Appearance, :header_logo]"
  10. # Favicon
  11. sudo -u git -H bundle exec rake "gitlab:uploads:migrate[FaviconUploader, Appearance, :favicon]"
  12. # Markdown
  13. sudo -u git -H bundle exec rake "gitlab:uploads:migrate[FileUploader, Project]"
  14. sudo -u git -H bundle exec rake "gitlab:uploads:migrate[PersonalFileUploader, Snippet]"
  15. sudo -u git -H bundle exec rake "gitlab:uploads:migrate[NamespaceFileUploader, Snippet]"
  16. sudo -u git -H bundle exec rake "gitlab:uploads:migrate[FileUploader, MergeRequest]"
  17. # Design Management design thumbnails
  18. sudo -u git -H bundle exec rake "gitlab:uploads:migrate[DesignManagement::DesignV432x230Uploader, DesignManagement::Action]"

Migrate to local storage

如果出于任何原因需要禁用对象存储 ,则必须首先将数据从对象存储中迁移出来,然后再迁移回本地存储中.

Warning: 需要延长停机时间 so no new files are created in object storage during the migration. A configuration setting will be added soon to allow migrating from object storage to local files with only a brief moment of downtime for configuration changes. To follow progress, see the relevant issue.

All-in-one Rake task

GitLab 提供了一个包装 Rake 任务,可将所有上载的文件(例如,头像,徽标,附件和网站图标)迁移到本地存储中. 包装器任务调用各个 Rake 任务来逐一迁移属于这些类别的文件.

有关这些 Rake 任务的详细信息,请参阅” 个人 Rake 任务” ,请记住,在这种情况下,任务名称为gitlab:uploads:migrate_to_local .

要将上传从对象存储迁移到本地存储:

  1. 同时禁用direct_uploadbackground_uploaduploads的设置gitlab.rb .
  2. 运行 Rake 任务:

    全部安装

    1. gitlab-rake "gitlab:uploads:migrate_to_local:all"

    源安装

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

运行 Rake 任务后,您可以通过撤消配置对象存储的说明中所述的更改来禁用对象存储 .