Gitlab 简明教程

GitLab - Restore Backup

GitLab 允许恢复存储库的备份副本。在本小节中,我们将讨论如何在 GitLab 中恢复备份副本 −

GitLab allows restoring the backup copy of your repository. In this chapter, we will discuss about how to restore the backup copy in the GitLab −

Step 1 − 首先,使用 SSH(安全外壳)登录到你的 GitLab 服务器。

Step 1 − First, login to your GitLab server using SSH (Secure Shell).

Step 2 − 在恢复备份副本之前,首先确保备份副本位于 /var/opt/gitlab/backups 目录中。

Step 2 − Before restoring the backup copy, first make sure backup copy is in the /var/opt/gitlab/backups directory.

Step 3 − 您可以使用 Create Backup 作业小节中描述的 ls -l 命令检查备份副本。

Step 3 − You can check the backup copy by using the ls -l command which is described in the Create Backup job chapter.

Step 4 − 现在,使用以下命令停止与数据库相关的进程 −

Step 4 − Now, stop the processes which are related to the database by using the below commands −

sudo gitlab-ctl stop unicorn

sudo gitlab-ctl stop sidekiq
restore backup 1

上述命令还可以通过关闭它们来临时释放一些内存。

The above commands can also be used to free up some memory temporarily by shutting down them.

Step 5 − 您可以使用以下命令验证 GitLab 服务的状态 −

Step 5 − You can verify status of the GitLab services by using the below command −

sudo gitlab-ctl status

Step 6 − 现在,使用备份副本的时间戳恢复备份 −

Step 6 − Now, restore the backup by using the timestamp of the backup copy −

sudo gitlab-rake gitlab:backup:restore BACKUP = 1521884424_2018_03_24_10.5.3
restore backup 2

Step 7 − 使用以下命令重新启动 GitLab 组件 −

Step 7 − Restart the GitLab components by using the below command −

sudo gitlab-ctl restart
restore backup 3

Step 8 − 现在按照以下所示方法清除数据库中的 GitLab −

Step 8 − Now check the GitLab by sanitizing the database as shown below −

sudo gitlab-rake gitlab:check SANITIZE = true
restore backup 4

SANITIZE = true 标志删除了所有电子邮件地址,因为它们是机密信息,并且删除了 CI 变量和访问令牌,因为它们可以在生产实例中使用。

The SANITIZE = true flag removes all email addresses because they are confidential, removes the CI variables and access tokens as they can be used in the production instance.