备份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

posted @ 2019-12-13 20:56  博客萨斯州  阅读(735)  评论(0编辑  收藏  举报