bitnami gitlab备份与恢复操作方法

bitnami gitlab备份与恢复操作方法

BitNami是一个开源项目,该项目产生的开源软件包括安装 Web应用程序和解决方案堆栈,以及虚拟设备.此文就不多介绍了,一键安装的解决方案

1.备份

不需要关闭gitlab服务

本文采用gitlab-8.7.3-0,安装路径/opt/gitlab-8.7.3-0

备份文件夹设置

/opt/gitlab-8.7.3-0/apps/gitlab/htdocs/config/gitlab.yml

 ## Backup settings
418   backup:
419     path: "tmp/backups"   # Relative paths are relative to Rails.root (default: tmp/backups/) //备份目录,默认/opt/gitlab-8.7.3-0/apps/gitlab/htdocs/tmp/backups/
420     # archive_permissions: 0640 # Permissions for the resulting backup.tar file (default: 0600) //备份文件权限
421     # keep_time: 604800   # default: 0 (forever) (in seconds) //备份文件保存时间
422     # pg_schema: public     # default: nil, it means that all schemas will be backed up
423     # upload: //上传云服务器保存,官方例程为亚马逊云
424     #   # Fog storage connection settings, see http://fog.io/storage/ .
425     #   connection:
426     #     provider: AWS
427     #     region: eu-west-1
428     #     aws_access_key_id: AKIAKIAKI
429     #     aws_secret_access_key: 'secret123'
430     #   # The remote 'directory' to store your backups. For S3, this would be the bucket name.
431     #   remote_directory: 'my.s3.bucket'
432     #   # Use multipart uploads when file size reaches 100MB, see
433     #   #  http://docs.aws.amazon.com/AmazonS3/latest/dev/uploadobjusingmpu.html
434     #   multipart_chunk_size: 104857600
435     #   # Turns on AWS Server-Side Encryption with Amazon S3-Managed Keys for backups, this is optional
436     #   # encryption: 'AES256'

备份操作

cd /opt/gitlab-8.7.3-0  //打开安装目录
./use_gitlab   //进入gitshell环境
cd /opt/gitlab-8.7.3-0/apps/gitlab/htdocs 
bundle exec bin/rake gitlab:backup:create RAILS_ENV=production

此时会在目录/opt/gitlab-8.7.3-0/apps/gitlab/htdocs/tmp/backups/下生成备份文件1541581050_gitlab_backup.tar

2.恢复操作

请确保设置的备份目录下有你想恢复的备份文件,本文备份文件夹为默认
所以拷贝备份文件/opt/gitlab-8.7.3-0/apps/gitlab/htdocs/tmp/backups/

cd /opt/gitlab-8.7.3-0  //打开安装目录
./use_gitlab   //进入gitshell环境
cd /opt/gitlab-8.7.3-0/apps/gitlab/htdocs 
bundle exec bin/rake  gitlab:backup:restore RAILS_ENV=production   BACKUP=备份文件的时间戳具体根据你想恢复文件的时间戳
chown git:git -R/opt/gitlab-8.7.3-0/apps/gitlab/repositories //修改文件所有者,因为以root操作备份,此步骤需要多次输入yes,会删除之前文件,恢复备份
chown git:git /opt/gitlab-8.7.3-0/apps/gitlab/gitlab-shell/gitlab-shell.log //没有这一步那么你就无法进行项目创建

3.手动定时备份

PATH="/opt/gitlab-8.7.3-0/apps/gitlabci/gitlabci-runner/bin:/opt/gitlab-8.7.3-0/apps/gitlab/gitlab-shell/bin:/opt/gitlab-8.7.3-0/redis/bin:/opt/gitlab-8.7.3-0/sqlite/bin:/opt/gitlab-8.7.3-0/python/bin:/opt/gitlab-8.7.3-0/perl/bin:/opt/gitlab-8.7.3-0/git/bin:/opt/gitlab-8.7.3-0/ruby/bin:/opt/gitlab-8.7.3-0/mysql/bin:/opt/gitlab-8.7.3-0/apache2/bin:/opt/gitlab-8.7.3-0/common/bin:$PATH"

echo "backup gitlab to local storage begin.. "

cd /opt/gitlab-8.7.3-0/apps/gitlab/htdocs

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

crontab 设置本脚本定时运行
为了增加备份安全性,上传百度云同步保存
采用开源百度云客户端 bypy https://github.com/houtianze/bypy
git clone 下来后,运行bypy,会出现一个链接,用网页打开链接后登录百度云账户,会出现一个密钥,之后复制到窗口下,之后就可以操作上传了.不过有一个问题就是密钥一个月后过期需要再次进行密钥获取认证

bypy upload 本地文件路径 服务器路径名称(gitlab/gitlab_backfile.tar)

参考:http://devzc.com/post/438
参考: https://community.bitnami.com/t/failed-to-create-repository-via-gitlab-shell/44670

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值