zoukankan      html  css  js  c++  java
  • gitlab备份and恢复数据

    备份数据

    1.确定备份的路径

    [root@localhost ~]# cat /etc/gitlab/gitlab.rb |grep backup_path
    # gitlab_rails['backup_path'] = "/var/opt/gitlab/backups"
    
    

    2.备份数据

    [root@localhost ~]# /usr/bin/gitlab-rake gitlab:backup:create
    [root@localhost ~]# ls /var/opt/gitlab/backups/1632002877_2021_09_19_12.3.5_gitlab_backup.tar 
    /var/opt/gitlab/backups/1632002877_2021_09_19_12.3.5_gitlab_backup.tar
    
    

    也可以做定时任务通过脚本备份

    [root@localhost ~]# crontab -l
    0 6 * * 0 /server/scripts/backup_gitlab.sh  2>&1 > /dev/null   #每周日的早上六点备份gitlab数据
    [root@localhost ~]# cat /server/scripts/backup_gitlab.sh 
    #!/bin/bash
    wx(){
         curl 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=b2d0bdd0-0177-441d-9406-cfce1f73fed9' 
       -H 'Content-Type: application/json' 
       -d '
       {
        "msgtype": "markdown",
        "markdown": {
            "content":  "'"$1"'"
        }
    
       }'
    }
    
    
    /usr/bin/gitlab-rake gitlab:backup:create
    if [ $? == 0 ];then
          scp -rp $(find /var/opt/gitlab/backups/  -type f ) root@192.168.1.53:/data/docker/yum/gitlab/backup && rm -rf /var/opt/gitlab/backups/* 
          if [ $? ==0 ];then
               rm -rf /var/opt/gitlab/backups/*
               ssh root@192.168.1.53 'find /data/docker/yum/gitlab/backup/ -type f   -mtime +30   |xargs -i rm -rf {} '
          else
               wx "## ${ZH_NAME} <font color=warning>gitlab备份数据传53送失败!</font> "
          fi
    else
         wx "## ${ZH_NAME} <font color=warning>gitlab备份数据失败!</font> "
    fi
    

    恢复数据

    1.下载安装包 汉化包

    wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-12.3.5-ce.0.el7.x86_64.rpm
    wget https://gitlab.com/xhang/gitlab/-/archive/v12.3.5-zh/gitlab-v12.3.5-zh.tar
    

    2.安装gitlab

    yum install -y curl postfix policycoreutils-python openssh-server wget
    yum localinstall gitlab-ce-12.3.5-ce.0.el7.x86_64.rpm -y
    

    3.修改对外暴露服务的端口号 时区

    [root@localhost gitlab]# vim /etc/gitlab/gitlab.rb
    #修改nginx端口号
    nginx[‘listen_port’] = 8088
    gitlab_rails['time_zone'] = 'Asia/Shanghai'
    
    [root@localhost gitlab]# gitlab-ctl reconfigure
    [root@localhost gitlab]# gitlab-ctl restart
    
    

    4.汉化

    #停止gitlab
    [root@localhost data]# gitlab-ctl stop
    
    #解压汉化包
    [root@localhost data]# tar xf gitlab-v12.3.5-zh.tar.gz 
    
    #覆盖语言包
    [root@localhost data]# cp -r gitlab-v12.3.5-zh/* /opt/gitlab/embedded/service/gitlab-rails/
    cp: 无法以目录"gitlab-v12.3.5-zh/log" 来覆盖非目录"/opt/gitlab/embedded/service/gitlab-rails/log"
    cp: 无法以目录"gitlab-v12.3.5-zh/tmp" 来覆盖非目录"/opt/gitlab/embedded/service/gitlab-rails/tmp"
    
    #开启gitlab
    [root@localhost data]# gitlab-ctl start
    

    5.恢复数据

    chmod 777 /var/opt/gitlab/backups/1632002877_2021_09_19_12.3.5_gitlab_backup.tar
    cd /var/opt/gitlab/backups
    gitlab-ctl stop unicorn && gitlab-ctl stop sidekiq
    gitlab-rake gitlab:backup:restore BACKUP=1632002877_2021_09_19_12.3.5
    
    

    参考文档: https://blog.csdn.net/w309827333/article/details/108754484

  • 相关阅读:
    提高CRM系统实施成功率
    CRM销售管理软件实施的误区
    ERP、CRM、SCM之间的区别
    选择CRM系统的四个步骤
    [导入]163相册验证码图片的识别手记之一 去除干扰
    [导入]C#中WebService里的回车符"\r"丢失问题
    [导入]文件同步精灵(初版)
    [导入]163相册验证码图片的识别手记之二 识别
    [导入]电信对我们的侵权行为如何能得到法律保护?
    [导入]认父亲的DbParameter!!
  • 原文地址:https://www.cnblogs.com/yangtao416/p/15320087.html
Copyright © 2011-2022 走看看