备份脚本:
#!/bin/bash
BackupDir=/data/docker/volumes/data_gitlab_data/_data/backups
BackupNum=(ls $BackupDir | wc -l)
#backup
docker exec -i gitlab gitlab-rake gitlab:backup:create
#clear backup
if[$BackupNum -gt 3];then
rm -f `find $BackupDir -name "gitlab_backup.tar" -mtime +3`
fi
迁徙和备份
docker save -o gitlab.tar gitlab/gitlab-ce:latest
导入镜像
docker load -i gitlab.tar
批改备份包的权限
chmod 777 1578900099_2020_01_13_12.6.0-ee_gitlab_backup.tar
进入容器,执行命令,进行相干服务:
gitlab-ctl stop unicorn #进行相干数据连贯服务
gitlab-ctl stop sidekiq
执行复原指令:依据提醒输出两次 yes
gitlab-rake gitlab:backup:restore BACKUP=1578900099_2020_01_13_12.6.0
重新启动 gitlab:gitlab-ctl start
Gitlab 迁徙和复原必须要留神一点,新的 gitlab 服务器版本号必须和之前的 gitlab 版本号统一