# 1. 检查当前版本
docker exec gitlab cat /opt/gitlabembedded/service/gitlab-rails/VERSION
# 2. 进入容器
docker exec -it gitlab bash
# 3. 备份文件 存储在 /var/opt/gitlab/backups/下面
gitlab-rake gitlab:backup:create
# 生成文件 /var/opt/gitlab/backups/1684222315_2023_05_16_15.11.3_gitlab_backup.tar
# 4. 复制上面的备份文件到 另外一台服务器,相同的路径 ,前提两台电脑已经添加秘钥
cp /home/gitlab/data/backups/1684222315_2023_05_16_15.11.3_gitlab_backup.tar
root@xxx.xx.xx.xx://home/gitlab/data/backups/
# 5. 进入容器
docker exec -it gitlab bash
# 6. 设置文件权限
chmod -R 777 1684222315_2023_05_16_15.11.3_gitlab_backup.tar
# 7. 停止数据库操作服务
gitlab-ctl stop unicorn
gitlab-ctl stop sidekiq
# 8. 开始还原 注意这里只需要写_gitlab_backup.tar 前面的文件名即可
gitlab-rake gitlab:backup:restore BACKUP=1684222315_2023_05_16_15.11.3
# 9. 重启服务
gitlab-ctl restart
version: '3'
services:
gitlab:
image: 'gitlab/gitlab-ce' # 这里一直修改 gitlab/gitlab-ce:11.0.6 gitlab/gitlab-ce:11.11.8
container_name: gitlab
restart: always
environment:
TZ: 'Asia/Shanghai'
GITLAB_OMNIBUS_CONFIG: |
gitlab_rails['time_zone'] = 'Asia/Shanghai'
ports:
- '7881:80'
- '7883:443'
- '7882:22'
volumes:
- /home/gitlab/config:/etc/gitlab
- /home/gitlab/data:/var/opt/gitlab
- /home/gitlab/logs:/var/log/gitlab
privileged: true