---
# System prepended metadata

title: GitLab Commnad
tags: [Git, ' Gitlab']

---

---
title: Gitlab Commnad
tags: Git, GitLab
description: GitLab Commnad
---

# GitLab Commnad

### 上傳文件到 gitlab asset

```
$  curl --request POST --header "Private-Token:XXXXXXXXXXXXXXXXXX" --form "file=@/home/<user>/docker-compose.yml" "http://localhost/api/v4/projects/<project-id>/uploads"
```

## gitlab備份還原

### 備份 gitlab 
```
$ /usr/bin/gitlab-rake gitlab:backup:create
```
備份資料會儲存於 `/var/opt/gitlab/backups/<backup_time>_gitlab_backup.tar`
![](https://i.imgur.com/36iyBSs.png)

### 還原 gitlab 

先停止會用到 shema 資料庫的servive，之後將備份資料用於 rollback ，之後再啟動先前停止的  service
```
$ gitlab-ctl stop unicorn
$ gitlab-ctl stop sidekiq
$ cd /var/opt/gitlab/backups
$ gitlab-rake gitlab:backup:restore BACKUP=<backup_time>
$ gitlab-ctl start unicorn
$ gitlab-ctl start sidekiq
```