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 任务将在下一部分中介绍.
要将所有上载从本地存储迁移到对象存储,请运行:
全部安装
gitlab-rake "gitlab:uploads:migrate:all"
源安装
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
.
全部安装
# 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, Note, :attachment]"
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, Note, :attachment]"
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]"
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
.
要将上传从对象存储迁移到本地存储:
- 同时禁用
direct_upload
和background_upload
下uploads
的设置gitlab.rb
. 运行 Rake 任务:
全部安装
gitlab-rake "gitlab:uploads:migrate_to_local:all"
源安装
sudo RAILS_ENV=production -u git -H bundle exec rake gitlab:uploads:migrate_to_local:all