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

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

手动配置较多,直接用集成包: bitnami-gitlab-6.4.3-1-linux-x64-installer.run

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

假定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."

gitlab备份与恢复操作方法的更多相关文章

  1. Git--07 Gitlab备份与恢复

    目录 Gitlab备份与恢复 01). 备份 02). 恢复 Gitlab备份与恢复 ​ 对gitlab进行备份将会创建一个包含所有库和附件的归档文件.对备份的恢复只能恢复到与备份时的gitlab相同 ...

  2. gitlab 备份与恢复

    1. gitlab 备份命令:# gitlab-rake gitlab:backup:create 1.1 查看备份文件(默认备份路径:/var/opt/gitlab/backups)# ls /va ...

  3. Gitlab备份与恢复、迁移与升级

    0.Gitlab安装 1.安装和配置必要的依赖关系 在CentOS7,下面的命令将在系统防火墙打开HTTP和SSH访问.   yum install curl openssh-server postf ...

  4. Gitlab备份与恢复[七]

    标签(linux): git 笔者Q:972581034 交流群:605799367.有任何疑问可与笔者或加群交流 备份 配置文件中加入 gitlab_rails['bakup_path']='/da ...

  5. gitlab备份与恢复

    (1)备份 1.创建备份目录,并授权 mkdir /data/backups/gitlab -pv chown -R git.git /data 2.修改gitlab配置 vim /etc/gitla ...

  6. 3、gitlab备份与恢复

    1.备份 #修改配置文件,启用备份 [root@localhost ~]# vim /etc/gitlab/gitlab.rb 377 gitlab_rails['backup_path'] = &q ...

  7. gitlab 从古老的 bitnami 版本 迁移到官方最新版本

    这是我之前发布在 yuque 的文章.是我刚来新公司的时候帮公司搬迁 git 记录下来的,现在看来去掉敏感部分直接发布也没啥问题啦,就搬家过来,我自己也方便查 XD . 8.1.6 -> 10. ...

  8. git学习------> Gitlab如何进行备份恢复与迁移?

    前段时间,在某台CenterOS服务器上搭建了Gitlab环境,并且大家陆陆续续的都把代码从svn迁移到了gitlab,但是之前的CenterOS服务器并不是搭建在公司的机房环境,而是搭建在办公室的某 ...

  9. GitLab 迁移与升级

    参考: [ 博客园 BigBao ] 环境说明: OS: CentOS 7.x gitlab-ce 初始版本: 8.8.5 gitlab-ce 升级到版本: 11.2.3 升级方式: rpm 安装升级 ...

随机推荐

  1. MySQL分支Percona, cmake编译安装

    Percona是在MySQL基础上改进的,在功能和性能上有着很显著的提升.该版本提升了在高负载情况下的InnoDB的性能,为DBA提供一些非常有用的性能诊断工具:另外有更多的参数和命令来控制服务器行为 ...

  2. Win7下使Users数据与程序分离

    大家知道,数据是用户最大的财富,但Windows系统默认的模式是将所有软件都安装在C盘,在Windows XP时代,数据文件夹会放在Document And Setting 目录下,在Win7时代,数 ...

  3. 【转】UIBezierPath精讲

    http://www.henishuo.com/uibezierpath-draw/ 基础知识 使用UIBezierPath可以创建基于矢量的路径,此类是Core Graphics框架关于路径的封装. ...

  4. C#多线程的几种实现方法

    1.最简单的多线程 using System; using System.Threading; namespace ThreadTest1 { public class SimpleThread { ...

  5. HDU 1702 队列与栈的简单运用http://acm.hdu.edu.cn/showproblem.php?pid=1702

    #include<stdio.h> #include<string.h> #include<queue> #include<stack> #define ...

  6. iOS 8版本信息与屏幕尺寸

    原文  http://www.cnblogs.com/smileEvday/p/iOS8.html   1.UIWindow的bounds iOS 7之前Window的bounds不会随着方向而变化, ...

  7. C#编程简短总结

    封装 field一般为private,定义的时候可以不赋值.不赋值的时候一般被构造函数初始化赋值,其值用来保存类实例的数据,可以被内部方法使用作为计算的数据来源.当需要继承类继承本类的时候,field ...

  8. iOS类别(Category)

    iOS类别(Category)与扩展(Extension) 苹果的官方文档 Category在iOS开发中使用非常频繁.尤其是在为系统类进行拓展的时候,我们可以不用继承系统类,直接给系统类添加方法,最 ...

  9. c语言向文件中写入

    创建一个文件使用fopen打开,然后使用fprintf输出,最后关闭文件流 FILE *out; out = fopen("test.txt","a+"); i ...

  10. Mysql中关于 group_concat函数详解

    group_concat()主要功能:能将相同的行组合起来 完整的语法如下: group_concat([DISTINCT] 要连接的字段 [Order BY ASC/DESC 排序字段] [Sepa ...