2018-02-24 22:12:11 -05:00
|
|
|
# Project import/export API
|
2018-02-13 09:04:19 -05:00
|
|
|
|
|
|
|
[Introduced][ce-41899] in GitLab 10.6
|
|
|
|
|
2018-02-16 08:37:26 -05:00
|
|
|
[See also the project import/export documentation](../user/project/settings/import_export.md)
|
2018-02-13 09:04:19 -05:00
|
|
|
|
2018-02-24 22:12:11 -05:00
|
|
|
## Schedule an export
|
2017-12-05 23:27:23 -05:00
|
|
|
|
|
|
|
Start a new export.
|
|
|
|
|
|
|
|
```http
|
|
|
|
POST /projects/:id/export
|
|
|
|
```
|
|
|
|
|
|
|
|
| Attribute | Type | Required | Description |
|
|
|
|
| --------- | -------------- | -------- | ---------------------------------------- |
|
|
|
|
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) owned by the authenticated user |
|
2018-03-14 10:17:35 -04:00
|
|
|
| `description` | string | no | Overrides the project description |
|
2017-12-05 23:27:23 -05:00
|
|
|
|
|
|
|
```console
|
2018-03-14 10:17:35 -04:00
|
|
|
curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" --form "description=Foo Bar" https://gitlab.example.com/api/v4/projects/1/export
|
2017-12-05 23:27:23 -05:00
|
|
|
```
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"message": "202 Accepted"
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## Export status
|
|
|
|
|
|
|
|
Get the status of export.
|
|
|
|
|
|
|
|
```http
|
|
|
|
GET /projects/:id/export
|
|
|
|
```
|
|
|
|
|
|
|
|
| Attribute | Type | Required | Description |
|
|
|
|
| --------- | -------------- | -------- | ---------------------------------------- |
|
|
|
|
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) owned by the authenticated user |
|
|
|
|
|
|
|
|
```console
|
|
|
|
curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/projects/1/export
|
|
|
|
```
|
|
|
|
|
|
|
|
Status can be one of `none`, `started`, or `finished`.
|
|
|
|
|
2018-02-28 22:30:47 -05:00
|
|
|
`_links` are only present when export has finished.
|
|
|
|
|
2017-12-05 23:27:23 -05:00
|
|
|
```json
|
|
|
|
{
|
|
|
|
"id": 1,
|
|
|
|
"description": "Itaque perspiciatis minima aspernatur corporis consequatur.",
|
|
|
|
"name": "Gitlab Test",
|
|
|
|
"name_with_namespace": "Gitlab Org / Gitlab Test",
|
|
|
|
"path": "gitlab-test",
|
|
|
|
"path_with_namespace": "gitlab-org/gitlab-test",
|
|
|
|
"created_at": "2017-08-29T04:36:44.383Z",
|
|
|
|
"export_status": "finished",
|
|
|
|
"_links": {
|
|
|
|
"api_url": "https://gitlab.example.com/api/v4/projects/1/export/download",
|
|
|
|
"web_url": "https://gitlab.example.com/gitlab-org/gitlab-test/download_export",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## Export download
|
|
|
|
|
|
|
|
Download the finished export.
|
|
|
|
|
|
|
|
```http
|
2018-02-24 22:12:11 -05:00
|
|
|
GET /projects/:id/export/download
|
2017-12-05 23:27:23 -05:00
|
|
|
```
|
|
|
|
|
|
|
|
| Attribute | Type | Required | Description |
|
|
|
|
| --------- | -------------- | -------- | ---------------------------------------- |
|
|
|
|
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) owned by the authenticated user |
|
|
|
|
|
|
|
|
```console
|
|
|
|
curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" --remote-header-name --remote-name https://gitlab.example.com/api/v4/projects/5/export/download
|
|
|
|
```
|
|
|
|
|
|
|
|
```console
|
|
|
|
ls *export.tar.gz
|
|
|
|
2017-12-05_22-11-148_namespace_project_export.tar.gz
|
|
|
|
```
|
|
|
|
|
2018-02-13 09:04:19 -05:00
|
|
|
## Import a file
|
|
|
|
|
|
|
|
```http
|
|
|
|
POST /projects/import
|
|
|
|
```
|
|
|
|
|
|
|
|
| Attribute | Type | Required | Description |
|
|
|
|
| --------- | -------------- | -------- | ---------------------------------------- |
|
2018-02-16 08:37:26 -05:00
|
|
|
| `namespace` | integer/string | no | The ID or path of the namespace that the project will be imported to. Defaults to the current user's namespace |
|
2018-02-13 09:04:19 -05:00
|
|
|
| `file` | string | yes | The file to be uploaded |
|
|
|
|
| `path` | string | yes | Name and path for new project |
|
|
|
|
|
|
|
|
To upload a file from your filesystem, use the `--form` argument. This causes
|
|
|
|
cURL to post data using the header `Content-Type: multipart/form-data`.
|
|
|
|
The `file=` parameter must point to a file on your filesystem and be preceded
|
|
|
|
by `@`. For example:
|
|
|
|
|
|
|
|
```console
|
2018-02-14 08:55:11 -05:00
|
|
|
curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" --form "path=api-project" --form "file=@/path/to/file" https://gitlab.example.com/api/v4/projects/import
|
2018-02-13 09:04:19 -05:00
|
|
|
```
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"id": 1,
|
|
|
|
"description": null,
|
|
|
|
"name": "api-project",
|
|
|
|
"name_with_namespace": "Administrator / api-project",
|
|
|
|
"path": "api-project",
|
|
|
|
"path_with_namespace": "root/api-project",
|
|
|
|
"created_at": "2018-02-13T09:05:58.023Z",
|
|
|
|
"import_status": "scheduled"
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## Import status
|
|
|
|
|
2018-02-13 09:12:18 -05:00
|
|
|
Get the status of an import.
|
2018-02-13 09:04:19 -05:00
|
|
|
|
|
|
|
```http
|
|
|
|
GET /projects/:id/import
|
|
|
|
```
|
|
|
|
|
|
|
|
| Attribute | Type | Required | Description |
|
|
|
|
| --------- | -------------- | -------- | ---------------------------------------- |
|
|
|
|
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) owned by the authenticated user |
|
|
|
|
|
|
|
|
```console
|
|
|
|
curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/projects/1/import
|
|
|
|
```
|
|
|
|
|
2018-02-13 09:12:18 -05:00
|
|
|
Status can be one of `none`, `scheduled`, `failed`, `started`, or `finished`.
|
|
|
|
|
2018-02-16 08:37:26 -05:00
|
|
|
If the status is `failed`, it will include the import error message under `import_error`.
|
2018-02-13 09:04:19 -05:00
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"id": 1,
|
|
|
|
"description": "Itaque perspiciatis minima aspernatur corporis consequatur.",
|
|
|
|
"name": "Gitlab Test",
|
|
|
|
"name_with_namespace": "Gitlab Org / Gitlab Test",
|
|
|
|
"path": "gitlab-test",
|
|
|
|
"path_with_namespace": "gitlab-org/gitlab-test",
|
|
|
|
"created_at": "2017-08-29T04:36:44.383Z",
|
|
|
|
"import_status": "started"
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
[ce-41899]: https://gitlab.com/gitlab-org/gitlab-ce/issues/41899
|