企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
# Uploads migrate Rake tasks > 原文:[https://docs.gitlab.com/ee/administration/raketasks/uploads/migrate.html](https://docs.gitlab.com/ee/administration/raketasks/uploads/migrate.html) * [Migrate to object storage](#migrate-to-object-storage) * [All-in-one Rake task](#all-in-one-rake-task) * [Individual Rake tasks](#individual-rake-tasks) * [Migrate to local storage](#migrate-to-local-storage) * [All-in-one Rake task](#all-in-one-rake-task-1) # Uploads migrate Rake tasks[](#uploads-migrate-rake-tasks-core-only "Permalink") `gitlab:uploads:migrate`在不同的存储类型之间迁移上载. ## Migrate to object storage[](#migrate-to-object-storage "Permalink") 在为 GitLab 的上传[配置对象存储](../../uploads.html#using-object-storage-core-only)后,使用此任务将现有的上传从本地存储迁移到远程存储. 阅读有关[在 GitLab 上](../../object_storage.html)使用[对象存储的](../../object_storage.html)更多信息. **注意:**所有处理将在后台工作人员中完成, **无需停机** . ### All-in-one Rake task[](#all-in-one-rake-task "Permalink") GitLab 提供了一个包装 Rake 任务,可将所有上载的文件(例如,头像,徽标,附件和网站图标)迁移到对象存储中. 包装器任务调用各个 Rake 任务来逐一迁移属于这些类别的文件. 这些[单独的 Rake 任务](#individual-rake-tasks)将在下一部分中介绍. 要将所有上载从本地存储迁移到对象存储,请运行: **全部安装** ``` gitlab-rake "gitlab:uploads:migrate:all" ``` **源安装** ``` sudo RAILS_ENV=production -u git -H bundle exec rake gitlab:uploads:migrate:all ``` ### Individual Rake tasks[](#individual-rake-tasks "Permalink") 如果您已经运行了[多合一 Rake 任务](#all-in-one-rake-task) ,则无需运行这些单独的任务. 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[](#migrate-to-local-storage "Permalink") 如果出于任何原因需要禁用[对象存储](../../object_storage.html) ,则必须首先将数据从对象存储中迁移出来,然后再迁移回本地存储中. **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](https://gitlab.com/gitlab-org/gitlab/-/issues/30979). ### All-in-one Rake task[](#all-in-one-rake-task-1 "Permalink") GitLab 提供了一个包装 Rake 任务,可将所有上载的文件(例如,头像,徽标,附件和网站图标)迁移到本地存储中. 包装器任务调用各个 Rake 任务来逐一迁移属于这些类别的文件. 有关这些 Rake 任务的详细信息,请参阅" [个人 Rake 任务"](#individual-rake-tasks) ,请记住,在这种情况下,任务名称为`gitlab:uploads:migrate_to_local` . 要将上传从对象存储迁移到本地存储: 1. 同时禁用`direct_upload`和`background_upload`下`uploads`的设置`gitlab.rb` . 2. 运行 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 ``` 运行 Rake 任务后,您可以通过撤消[配置对象存储](../../uploads.html#using-object-storage-core-only)的说明中所述的更改来禁用[对象存储](../../uploads.html#using-object-storage-core-only) .