Chinaunix首页 | 论坛 | 博客
  • 博客访问: 629735
  • 博文数量: 85
  • 博客积分: 1306
  • 博客等级: 中尉
  • 技术积分: 990
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-28 11:23
个人简介

嵌入式视频行业。

文章分类

全部博文(85)

文章存档

2015年(7)

2014年(5)

2013年(41)

2012年(11)

2011年(1)

2010年(3)

2008年(17)

分类: LINUX

2014-12-16 13:55:36

gitlab备份与恢复操作方法

github私有仓库是收费的,有些代码不方便托管到外面的git仓库,因此就产生了自己搭建git服务器的需求。

好在有广大的开源人士的贡献,有了这一神器。

手动配置较多,直接用集成包: 

=============================

假定gitlab安装路径为: /opt/gitlab-6.4.3-1/

全程以root用户操作。
1.设定备份目录:
/opt/gitlab-6.4.3-1/apps/gitlab/htdocs/config/gitlab.yml

2.备份:

有些时候会报错: You have already activated rake 0.9.2.2,but our Gemfile requires rake 10.1.0,Using bundle exec may solve this.

原因是默认的path路径不对,需要执行下bitnami自带的环境变量设置脚本: use_gitlab 即可解决。


cd /opt/gitlab-6.4.3-1/
./use_gitlab
cd /opt/gitlab-6.4.3-1/apps/gitlab/htdocs
bundle exec bin/rake gitlab:backup:create RAILS_ENV=production


3.恢复:
BACKUP=timestamp_of_backup  #(required if more than one backup exists):

cd /opt/gitlab-6.4.3-1/
./use_gitlab
cd /opt/gitlab-6.4.3-1/apps/gitlab/htdocs
bundle exec bin/rake  gitlab:backup:restore RAILS_ENV=production   BACKUP=1405247282
chown git:git -R /opt/gitlab-6.4.3-1/apps/gitlab/repositories


4.crontab定时备份脚本参考:

 use_gitlab使用了exec,脚本会重新打开一个进程,没有上下文,所以需要单独提出path.

脚本需要使用root账户运行。脚本包含了rsync远程同步到nas相应目录中,按照自己实际修改即可(预先生成ssh证书,免密码登录)。


#!/bin/bash if [ `id -u` -ne 0 ];then
   echo "this backup script must be exec as root." exit
fi
date
PATH="/opt/gitlab-6.4.3-1/apps/gitlabci/gitlabci-runner/bin:/opt/gitlab-6.4.3-1/apps/gitlab/gitlab-shell/bin:/opt/gitlab-6.4.3-1/redis/bin:/opt/gitlab-6.4.3-1/sqlite/bin:/opt/gitlab-6.4.3-1/python/bin:/opt/gitlab-6.4.3-1/perl/bin:/opt/gitlab-6.4.3-1/git/bin:/opt/gitlab-6.4.3-1/ruby/bin:/opt/gitlab-6.4.3-1/mysql/bin:/opt/gitlab-6.4.3-1/apache2/bin:/opt/gitlab-6.4.3-1/common/bin:$PATH" echo "backup gitlab to local storage begin.. " cd /opt/gitlab-6.4.3-1/apps/gitlab/htdocs

bundle exec bin/rake gitlab:backup:create RAILS_ENV=production

echo "rsync  -avzP  --delete  /data/backups_gitlab xxx@xxx.com:/mnt/disk1/docs/rsync_gitlab_backup" rsync -avzP --delete /data/backups_gitlab xxx@xxx.com:/mnt/disk1/docs/rsync_gitlab_backup/ date
echo "this job is end."
阅读(6162) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~