1.gitlab 服务备份脚本和恢复git
#!/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