Centos7-GitLab 备份与还原
本文最后更新于 1476 天前,其中的信息可能已经有所发展或是发生改变。

Centos7-GitLab 备份与还原

备份

宿主机部署的GitLab

gitlab-rake gitlab:backup:create

Docker部署的Gitlab

docker exec gitlab gitlab-rake gitlab:backup:create

这里的gitlab 就是您的容器名称

备份完成后,/var/opt/gitlab/backups 目录会生成文件名是 [TIMESTAMP]_gitlab_backup.tar 的备份文件.

如果docker 做了目录映射,则自行判断

还原

上传 [TIMESTAMP]_gitlab_backup.tar 文件到 /var/opt/gitlab/backups/ 目录

停止 gitlab 服务

gitlab-ctl stop unicorn
gitlab-ctl stop sidekiq
gitlab-ctl status

docker部署同理~进入docker容器停止即可

执行还原命令

gitlab-rake gitlab:backup:restore BACKUP=1659555181_2022_08_03

重启

gitlab-ctl restart

检查 gitlab 状态

gitlab-ctl status
gitlab-rake gitlab:check SANITIZE=true

Docker环境下,每日定时备份

备份脚本如下:

[root@gitlab ~]# cat /root/gitlab_backup.sh
#! /bin/bash
case "$1" in
    start)

            docker exec gitlab gitlab-rake gitlab:backup:create

            sleep 30

            find "/data/gitlab/data/backups" -name "*.tar" -ctime +3 -type f -exec rm -rf {} \;

            ;;
esac


[root@gitlab ~]# crontab -l
0 2 * * * /root/gitlab_backup.sh start

如需要验证,可安装同版本的 gitlab

docker 部署命令:

docker run --detach --publish 443:443 \
--publish 19922:22 --publish 80:80  \
--name gitlab --restart always \
--volume /data/gitlab/config:/etc/gitlab \
--volume /data/gitlab/logs:/var/log/gitlab \
--volume /data/gitlab/data:/var/opt/gitlab \
gitlab/gitlab-ce:9.0.0-ce.0
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇