# Repository storage Rake tasks > 原文:[https://docs.gitlab.com/ee/administration/raketasks/storage.html](https://docs.gitlab.com/ee/administration/raketasks/storage.html) * [List projects and attachments](#list-projects-and-attachments) * [On legacy storage](#on-legacy-storage) * [On hashed storage](#on-hashed-storage) * [Migrate to hashed storage](#migrate-to-hashed-storage) * [Rollback from hashed storage to legacy storage](#rollback-from-hashed-storage-to-legacy-storage) # Repository storage Rake tasks[](#repository-storage-rake-tasks-core-only "Permalink") 这是 Rake 任务的集合,可帮助您列出现有项目及其附件并将其迁移到新的[哈希存储中](../repository_storage_types.html) ,GitLab 用于组织 Git 数据. ## List projects and attachments[](#list-projects-and-attachments "Permalink") 以下 Rake 任务将列出旧版存储和哈希存储上可用的项目和附件. ### On legacy storage[](#on-legacy-storage "Permalink") 要使用旧式存储获得摘要,然后列出项目及其附件: * **全部安装** ``` # Projects sudo gitlab-rake gitlab:storage:legacy_projects sudo gitlab-rake gitlab:storage:list_legacy_projects # Attachments sudo gitlab-rake gitlab:storage:legacy_attachments sudo gitlab-rake gitlab:storage:list_legacy_attachments ``` * **源码安装** ``` # Projects sudo -u git -H bundle exec rake gitlab:storage:legacy_projects RAILS_ENV=production sudo -u git -H bundle exec rake gitlab:storage:list_legacy_projects RAILS_ENV=production # Attachments sudo -u git -H bundle exec rake gitlab:storage:legacy_attachments RAILS_ENV=production sudo -u git -H bundle exec rake gitlab:storage:list_legacy_attachments RAILS_ENV=production ``` ### On hashed storage[](#on-hashed-storage "Permalink") 要使用散列存储来获得项目及其附件的摘要和列表,请执行以下操作: * **全部安装** ``` # Projects sudo gitlab-rake gitlab:storage:hashed_projects sudo gitlab-rake gitlab:storage:list_hashed_projects # Attachments sudo gitlab-rake gitlab:storage:hashed_attachments sudo gitlab-rake gitlab:storage:list_hashed_attachments ``` * **源码安装** ``` # Projects sudo -u git -H bundle exec rake gitlab:storage:hashed_projects RAILS_ENV=production sudo -u git -H bundle exec rake gitlab:storage:list_hashed_projects RAILS_ENV=production # Attachments sudo -u git -H bundle exec rake gitlab:storage:hashed_attachments RAILS_ENV=production sudo -u git -H bundle exec rake gitlab:storage:list_hashed_attachments RAILS_ENV=production ``` ## Migrate to hashed storage[](#migrate-to-hashed-storage "Permalink") **注意:**在 GitLab 13.0 中,默认情况下启用了[哈希存储](../repository_storage_types.html#hashed-storage) ,并且不建议使用旧存储. 在 GitLab 14.0 中将删除对旧存储的支持. 如果您使用的是 GitLab 13.0 及更高版本,则无法将新项目切换到旧版存储. 在管理区域中的哈希存储和旧存储之间进行选择的选项已被禁用. 此任务将安排您所有与之关联的现有项目和附件,以迁移到**Hashed**存储类型: * **全部安装** ``` sudo gitlab-rake gitlab:storage:migrate_to_hashed ``` * **源码安装** ``` sudo -u git -H bundle exec rake gitlab:storage:migrate_to_hashed RAILS_ENV=production ``` 如果您有任何现有的集成,则可能需要先进行少量部署以进行验证. 您可以通过使用环境变量`ID_FROM`和`ID_TO`在操作中指定 ID 范围来`ID_TO` . 例如,要在 Omnibus GitLab 安装中将项目 ID 限制为项目 ID 50 到 100: ``` sudo gitlab-rake gitlab:storage:migrate_to_hashed ID_FROM=50 ID_TO=100 ``` 您可以在 **管理区域>监视>后台作业**页面. 您可以观看一个特定的队列,以了解完成需要多长时间: `hashed_storage:hashed_storage_project_migrate` . 达到零后,您可以通过运行以下命令确认每个项目都已迁移. 如果发现有必要,则可以再次运行此迁移脚本以计划丢失的项目. 任何错误或警告将记录在 Sidekiq 的日志文件中. **注意:**如果启用了" [地理"](../geo/replication/index.html) ,则成功迁移的每个项目都会生成一个事件,以复制任何**辅助**节点上的更改. 您只需要`gitlab:storage:migrate_to_hashed` Rake 任务即可迁移存储库,但是下面还有其他命令可帮助您检查旧版存储和哈希存储中的项目和附件. ## Rollback from hashed storage to legacy storage[](#rollback-from-hashed-storage-to-legacy-storage "Permalink") **不建议使用:**在 GitLab 13.0 中,默认情况下启用了[哈希存储](../repository_storage_types.html#hashed-storage) ,并且不建议使用旧存储. 在 GitLab 14.0 中将删除对旧存储的支持. 如果您使用的是 GitLab 13.0 及更高版本,则无法将新项目切换到旧版存储. 在管理区域中的哈希存储和旧存储之间进行选择的选项已被禁用. This task will schedule all your existing projects and associated attachments to be rolled back to the legacy storage type. * **全部安装** ``` sudo gitlab-rake gitlab:storage:rollback_to_legacy ``` * **源码安装** ``` sudo -u git -H bundle exec rake gitlab:storage:rollback_to_legacy RAILS_ENV=production ``` 如果您有任何现有的集成,则可能需要先进行少量回滚以进行验证. 您可以通过使用环境变量`ID_FROM`和`ID_TO`在操作中指定 ID 范围来`ID_TO` . 例如,要在 Omnibus GitLab 安装中将项目 ID 限制为项目 ID 50 到 100: ``` sudo gitlab-rake gitlab:storage:rollback_to_legacy ID_FROM=50 ID_TO=100 ``` 您可以在 **管理区域>监视>后台作业**页面. 在" **队列"**选项卡上,您可以查看`hashed_storage:hashed_storage_project_rollback`队列以查看该过程将花费多长时间. 达到零后,您可以通过以下命令确认每个项目都已回滚. 如果某些项目没有回滚,则可以再次运行此回滚脚本以安排进一步的回滚. 任何错误或警告将记录在 Sidekiq 的日志文件中. 如果您具有地理设置,则回滚将不会自动反映在**辅助**节点上. 您可能需要等待回填操作才能启动,并手动从特殊的`@hashed/`文件夹中删除剩余的存储库.