BitNami是一个开源项目,该项目产生的开源软件包括安装 Web应用程序和解决方案堆栈,以及虚拟设备.此文就不多介绍了,一键安装的解决方案
不需要关闭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
请确保设置的备份目录下有你想恢复的备份文件,本文备份文件夹为默认
所以拷贝备份文件/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 //没有这一步那么你就无法进行项目创建
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