1.启动gitlab
docker run --name gitlab-bak1 \
-p 2022:22 -p 2080:80 -p 2443:443 -d \
-v /opt/gitlab_bak1/config:/etc/gitlab \
-v /opt/gitlab_bak1/logs:/var/log/gitlab \
-v /opt/gitlab_bak1/data:/var/opt/gitlab \
gitlab/gitlab-ce:16.2.1-ce.0
2.修改配置文件/opt/gitlab_bak1/config/gitlab.rb
gitlab_rails['manage_backup_path'] = true
gitlab_rails['backup_path'] = "/var/opt/gitlab/backups"
gitlab_rails['backup_archive_permissions'] = 0644
gitlab_rails['backup_keep_time'] = 604800
3.重新加载配置
docker exec -t gitlab-bak1 gitlab-ctl reconfigure
4.复制备份文件到2指定的目录
cp /opt/gitlab/gitlab/data/backups/1705891184_2024_01_22_16.2.1_gitlab_backup.tar /opt/gitlab_bak1/data/backups/
5.停止连接到数据库的进程
docker exec -it gitlab-bak1 gitlab-ctl stop puma
docker exec -it gitlab-bak1 gitlab-ctl stop sidekiq
docker exec -it gitlab-bak1 gitlab-ctl status
6.恢复,名称中省略了_gitlab_backup.tar
docker exec -it gitlab-bak1 gitlab-backup restore BACKUP=1705891184_2024_01_22_16.2.1
7.恢复gitlab-secrets文件
tar -xf /opt/gitlab/config/config_backup/gitlab_config_1705891508_2024_01_22.tar -C /tmp/ && mv -f /tmp/etc/gitlab/gitlab-secrets.json /opt/gitlab_bak1/config/
8.重启gitlab容器
docker restart gitlab-bak1
9.检查
docker exec -it gitlab-bak1 gitlab-rake gitlab:check SANITIZE=true