gitlab备份-源码安装

手动备份:

cd /home/git/gitlab

sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production STRATEGY=copy

注:跳过某些内容sudo -u git -H bundle exec rake gitlab:backup:create SKIP=db,uploads RAILS_ENV=production

skip为:

db (database)
uploads (attachments)
repositories (Git repositories data)
builds (CI job output logs)
artifacts (CI job artifacts)
lfs (LFS objects)
registry (Container Registry images)
pages (Pages content)


2、自动备份:crontab学习可以看我另外一篇文章Linux定时任务cron和crontab

cd /home/git/gitlab
sudo -u git -H vim config/gitlab.yml # Enable keep_time in the backup section to automatically delete old backups
sudo -u git crontab -e # Edit the crontab for the git user

添加如下内容:

# Create a full backup of the GitLab repositories and SQL database every day at 4am
0 4 * * * cd /home/git/gitlab && PATH=/usr/local/bin:/usr/bin:/bin bundle exec rake gitlab:backup:creat


3、还原

cd /home/git/gitlab

bundle exec rake gitlab:backup:restore RAILS_ENV=productione RAILS_ENV=production CRON=1

如果备份目录下面有多个备份文件,则需加参数并指明时间戳

BACKUP=timestamp_of_backup (required if more than one backup exists)
force=yes (do not ask if the authorized_keys file should get regenerated)


4、备份注意事项:

还需要备份文件:/home/git/gitlab/config/secrets.yml(两步验证时用到:用户名密码登录及短信验证)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值