其他分享
首页 > 其他分享> > 备份docker运行的gitlab

备份docker运行的gitlab

作者:互联网

#!/bin/bash

data=$(date "+%Y-%m-%d %H:%M:%S")
gitBak='/data/gitlab/data/backups'
delFile=`ls -l -crt  $gitBak/*.tar | awk '{print $9 }' | head -1`
count=`ls -l -crt  $gitBak/*.tar | awk '{print $9 }' | wc -l`

if [ $count -gt 9 ];then
  rm $delFile
  echo "$data -- delete $delFile" >> $gitBak/del_log.txt
fi

docker exec gitlab gitlab-rake gitlab:backup:create RAILS_ENV=production CRON=1

if [ $? -ne 0 ];then
  echo "$data -- 脚本执行失败" >> $gitBak/back_log.txt
fi

标签:tar,delFile,备份,gitlab,echo,gitBak,docker,data
来源: https://www.cnblogs.com/fan-gx/p/12037264.html