数据备份
进入容器中,备份数据
bundle exec rake gitlab:backup:create RAILS_ENV=production
恢复数据
[root@test ~]# docker exec -it 05b739655a3a /bin/bash -c " bundle exec rake gitlab:backup:restore BACKUP=1508807622_2017_10_24"
报错:
Unpacking backup ... tar: 1508807622_2017_10_24_gitlab_backup.tar: Cannot open: Permission denied
tar: Error is not recoverable: exiting now
unpacking backup failed
迁移的备份文件权限不足,可以给足权限,然后再恢复。
进入容器:
[root@test ~]# docker exec -it 05b739655a3a /bin/bash
数据备份是在/home/git/data/backups,但是数据恢复的时候默认去了/home/git/gitlab/backups,手动创建该目录并且将备份的数据cp至/home/git/gitlab/backups目录下。
root@test:~# mkdir /home/git/gitlab/backups
root@test:~# chown git /home/git/gitlab/backups
root@test:~# chmod 700 /home/git/gitlab/backups
如果还有报错,执行如下命令追踪报错的过程。
[root@test ~]# docker exec -it 05b739655a3a /bin/bash -c " bundle exec rake gitlab:backup:restore BACKUP=1508807622_2017_10_24 --strace"
数据恢复:
[root@test ~]# docker exec -it 05b739655a3a /bin/bash -c " bundle exec rake gitlab:backup:restore BACKUP=1508807622_2017_10_24 "
Warning
You are running as user root, we hope you know what you are doing.
Things may work/fail for the wrong reasons.
For correct results you should run this as user git.
Unpacking backup ... done
Before restoring the database we recommend removing all existing
tables to avoid future upgrade problems. Be aware that if you have
custom tables in the GitLab database these tables and all data will be
removed.
Do you want to continue (yes/no)? yes
Removing all tables. Press `Ctrl-C` within 5 seconds to abort
Cleaning the database ...
done
Restoring database ...
Restoring MySQL database gitlabhq_production ... [DONE]
done
Restoring repositories ...
* jianwei15/proxyscripts ... [DONE]
* test/aaa ... [DONE]
* test/fx ... [DONE]
* test/admin-ui ...
Put GitLab hooks in repositories dirs [DONE]
done
Restoring uploads ...
done
Restoring builds ...
done
Restoring artifacts ...
done
Restoring pages ...
done
Restoring lfs objects ...
done
This will rebuild an authorized_keys file.
You will lose any data stored in authorized_keys file.
Do you want to continue (yes/no)? yes
至此,数据恢复完成。
登录后查看数据是否有丢失,发现 No repository,很可能是repositories目录下的owner和gitlab的不匹配,执行如下命令,清理缓存
image.png
登录容器运行命令,将owner赋给gitlab的owner:
[root@test ~]# docker exec -it 45764742d90f /bin/bash
[root@test ~]#chown -R git:git /home/git/data/repositories/*
如果依然有此提示,需要清除一下缓存:
[root@test ~]# docker exec -it 24d0ddeeebe7 /bin/bash -c "bundle exec rake gitlab:backup:clear RAILS_ENV=production"
刷新页面查看,是否恢复。
网友评论