Skip to content
代码片段 群组 项目
提交 6410720c 编辑于 作者: Evan Read's avatar Evan Read
浏览文件

Merge branch 'benjaminking-remove-import-export-cheatsheet' into 'master'

Remove the "import/export" section of the Rails cheat sheet

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/102135



Merged-by: default avatarEvan Read <eread@gitlab.com>
Approved-by: default avatarEvan Read <eread@gitlab.com>
Co-authored-by: default avatarCynthia "Arty" Ng <cng@gitlab.com>
Co-authored-by: default avatarBen King <bking@gitlab.com>
No related branches found
No related tags found
无相关合并请求
......@@ -28,77 +28,6 @@ mentioned above, we recommend running these scripts under the supervision of a
Support Engineer, who can also verify that they continue to work as they
should and, if needed, update the script for the latest version of GitLab.
## Imports and exports
### Import a project
```ruby
# Find the project and get the error
p = Project.find_by_full_path('<username-or-group>/<project-name>')
p.import_error
# To finish the import on GitLab running version before 11.6
p.import_finish
# To finish the import on GitLab running version 11.6 or after
p.import_state.mark_as_failed("Failed manually through console.")
```
### Rename imported repository
In a specific situation, an imported repository needed to be renamed. The Support
Team was informed of a backup restore that failed on a single repository, which created
the project with an empty repository. The project was successfully restored to a development
instance, then exported, and imported into a new project under a different name.
The Support Team was able to transfer the incorrectly named imported project into the
correctly named empty project using the steps below.
Move the new repository to the empty repository:
```shell
mv /var/opt/gitlab/git-data/repositories/<group>/<new-project> /var/opt/gitlab/git-data/repositories/<group>/<empty-project>
```
Make sure the permissions are correct:
```shell
chown -R git:git <path-to-directory>.git
```
Clear the cache:
```shell
sudo gitlab-rake cache:clear
```
### Export a project
It's typically recommended to export a project through [the web interface](../../user/project/settings/import_export.md#export-a-project-and-its-data) or through [the API](../../api/project_import_export.md). In situations where this is not working as expected, it may be preferable to export a project directly via the Rails console:
```ruby
user = User.find_by_username('<username>')
# Sufficient permissions needed
# Read https://docs.gitlab.com/ee/user/permissions.html#project-members-permissions
project = Project.find_by_full_path('<username-or-group>/<project-name')
Projects::ImportExport::ExportService.new(project, user).execute
```
If this all runs successfully, you see an output like the following before being returned to the Rails console prompt:
```ruby
=> nil
```
The exported project is located in a `.tar.gz` file in `/var/opt/gitlab/gitlab-rails/uploads/-/system/import_export_upload/export_file/`.
If this fails, [enable verbose logging](../operations/rails_console.md#looking-up-database-persisted-objects),
repeat the above procedure after,
and report the output to
[GitLab Support](https://about.gitlab.com/support/).
## Mirrors
### Find mirrors with "bad decrypt" errors
......
......@@ -382,9 +382,9 @@ Rather than attempting to push all changes at once, this workaround:
### Manually execute export steps
Exports sometimes fail without giving enough information to troubleshoot. In these cases, it can be
helpful to [open a rails console session](../../../administration/operations/rails_console.md#starting-a-rails-console-session)
and loop through [all the defined exporters](https://gitlab.com/gitlab-org/gitlab/-/blob/b67a5b5a12498d57cd877023b7385f7251e57de8/app/services/projects/import_export/export_service.rb#L65).
You usually export a project through [the web interface](#export-a-project-and-its-data) or through [the API](../../../api/project_import_export.md). Exporting using these
methods can sometimes fail without giving enough information to troubleshoot. In these cases,
[open a rails console session](../../../administration/operations/rails_console.md#starting-a-rails-console-session)
Execute each line individually, rather than pasting the entire block at once, so you can see any
errors each command returns.
......@@ -406,6 +406,8 @@ s.send(:compress_and_save)
s.send(:save_upload)
```
After the project is successfully uploaded, the exported project is located in a `.tar.gz` file in `/var/opt/gitlab/gitlab-rails/uploads/-/system/import_export_upload/export_file/`.
### Import using the REST API fails when using a group access token
[Group access tokens](../../group/settings/group_access_tokens.md)
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册