gitlab备份-源码安装

来源:互联网 发布:抢演唱会门票软件 编辑:程序博客网 时间:2024/06/06 03:27

手动备份:

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(两步验证时用到:用户名密码登录及短信验证)

0 0