gitlab的备份与恢复

前几天公司的gitlab服务器,因为异常断电,重启服务器之后,服务起不来,原来是gitlab-6.4.3的版本。

系统环境:centos6.5

IP地址:192.168.1.8(以下称M8)

IP地址:192.168.1.9(以下称M9)

需求:M9重新安装gitlab服务,将M8上的版本库数据迁移到M9上。

1、重新在M9这台centos服务器上安装gitlab。安装方法参考:https://www.funet8.com/2330.html

然后在坏掉的版本库服务器上备份工程文件:

[root@localhost htdocs]# cd /opt/gitlab-6.4.3-0/apps/gitlab/
[root@localhost gitlab]# tar -zcvf repositories.tar.gz repositories/

复制到M9服务器上

[root@localhost gitlab]# scp  /opt/gitlab-6.4.3-0/apps/gitlab/repositories.tar.gz root@192.168.1.9:/var/opt/gitlab/git-data/repositories/repositories.tar.gz

这样就只是重新将M8上的版本库文件复制到M9上,还需要新建git项目和用户。

这种恢复的方法比较麻烦,因为没有M8上没有做gitlab的备份!

 gitlab的备份与恢复

2、M9上操作,新建备份目标目录:

[root@localhost ~]# mkdir /home/git_bak
[root@localhost ~]# chown git:root -R /home/git_bak/

vi /opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml
## Backup settings
  backup:
    path: "/var/opt/gitlab/backups" 

改为:

  ## Backup settings
  backup:
    path: "/home/git_bak"

有的linux系统是需要改此文件: /etc/gitlab/gitlab.rb
 

[root@localhost ~]# gitlab-ctl restart        【重启】
[root@localhost ~]# /opt/gitlab/bin/gitlab-rake gitlab:backup:create    【备份git】

恢复备份方法:

[root@localhost backups]# gitlab-ctl stop unicorn
[root@localhost backups]# gitlab-ctl stop sidekiq
[root@localhost backups]# gitlab-rake gitlab:backup:restore BACKUP=1459415571    【恢复备份修改 BACKUP后面的参数】
Unpacking backup ...
[root@localhost backups]# gitlab-ctl start

Gitlab迁移

把备份文件拷贝到gitlab的备份目录下,根据上面gitlab恢复步骤即可。    

gitlab定时自动备份

新建一个shell脚本文档:/home/git_bak/gitbak.sh

#!/bin/sh
/opt/gitlab/bin/gitlab-rake gitlab:backup:create
vi /etc/crontab
00 2 * * * root /home/git_bak/gitbak.sh >> /home/git_bak/gitbak.log
[root@localhost backups]# service crond restart

/var/opt/gitlab/                                    【gitlab所有的工程目录都在】
/var/opt/gitlab/git-data/repositories        【版本库文件】 
/var/opt/gitlab/backups                        【默认备份目录,修改此目录】

版本库服务器异常断电之后,如果页面有50x提示,使用最新的备份文件恢复过来就好了


 参考地址: http://www.ithao123.cn/content-10080199.html

评论

  1. 8年前
    2016-4-08 14:42:26

    我就进来看看

  2. 8年前
    2016-4-15 11:07:07

    我靠 你的百度联盟怎么关闭了

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇