首页 > 其他 > 详细

gitlab 备份恢复脚本

时间:2020-12-14 22:07:56      阅读:32      评论:0      收藏:0      [点我收藏+]
1.gitlab 服务备份脚本和恢复

#!/bin/bash
backupDir="/chj/data/BackupData"

function checkNewFile(){
find $backupDir -name "*_gitlab_backup.tar"|head -1|xargs rm -vf
}

function restoreCopyData(){
restoreDir=$(ls -ltd /mnt/tools/bakups/* |awk ‘{if(NR<=1){print $9}}‘)
yes|cp -rpf $restoreDir $backupDir
}

function stopConnection(){
gitlab-ctl stop sidekiq
gitlab-ctl stop unicorn
}

function restoreData(){
cd $backupDir
gitlab-rake gitlab:backup:restore

}

function bakcupGitlab(){
cd $backupDir
gitlab-rake gitlab:backup:create
}

function startService(){
gitlab-ctl reconfigure
gitlab-ctl restart
}

function main(){
checkNewFile
restoreCopyData
stopConnection
restoreData
startService
}

case $1 in 
    "all")
        main $*
        ;;
    "CheckNewFile")
        checkNewFile 
        ;;
    "restartService")
        startService 
        ;;
    "restoreData")
        checkNewFile
        stopConnection
        restoreCopyData   
        ;;
    "bakcupGitlab")
      bakcupGitlab
       ;;
    *)
echo    -e "\033[32m 参数如下: \033[0m"
        echo -e "\033[32m CheckNewFile \033[0m 检查数据文件,清理历史文件"
        echo -e "\033[32m startService \033[0m 重启系统服务"
        echo -e "\033[32m restoreData \033[0m 恢复gitlab数据"
        echo -e "\033[32m bakcupGitlab \033[0m 备份gitlab数据"
        ;;
esac

gitlab 备份恢复脚本

原文:https://blog.51cto.com/breaklinux/2564101

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!