gitlab备份与恢复

1.docker-compose部署gitlab
cat docker-compose.yaml
version: '3.6'
services:
web:
image: 'gitlab/gitlab-ce:17.4.2-ce.0'
restart: always
hostname: 'git.ope.ai'
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'http://git.aa.ai:8999'
gitlab_rails['gitlab_shell_ssh_port'] = 8222
ports:
- '8999:8999'
- '8222:22'
volumes:
- ./config:/etc/gitlab
- ./logs:/var/log/gitlab
- ./data:/var/opt/gitlab
shm_size: '256m'

2.常用备份命令
默认备份目录为/var/opt/gitlab/backups
也可能为/home/gitlab
docker exec gitlab-web1 gitlab-backup create (适合数据量小)
docker exec gitlab-web1 gitlab-rake gitlab:backup:create STRATEGY=copy (更适合数据量大时,会占用更多的磁盘)

3.gitlab数据恢复命令
(1)恢复备份 当你需要从备份中恢复时,首先确保 GitLab 已停止服务:
sudo gitlab-ctl stop unicorn
sudo gitlab-ctl stop sidekiq
(2)然后移动备份文件到 GitLab 备份目录,并执行恢复命令:
sudo gitlab-backup restore BACKUP=
其中 是你要恢复的备份文件名中的时间戳部分。
(3)最后重启 GitLab:
sudo gitlab-ctl start

posted @ 2025-05-08 16:11  A学无止境A  阅读(578)  评论(0)    收藏  举报