1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| #!/bin/bash export $PATH
echo "开始执行gitlab备份命令..." timer_start=`date "+%Y-%m-%d %H:%M:%S"`
docker exec gitlab-web-1 gitlab-backup create
timer_end=`date "+%Y-%m-%d %H:%M:%S"` duration=`echo $(($(date +%s -d "${timer_end}") - $(date +%s -d "${timer_start}"))) | awk '{t=split("60 s 60 m 24 h 999 d",a);for(n=1;n<t;n+=2){if($1==0)s="0s";break;s=$1%a[n]a[n+1]s;$1=int($1/a[n])}print s}'`
echo "gitlab备份命令执行结束,耗时 $duration "
echo "开始移动备份文件至指定备份区域..." mv /usr/local/Gitlab/data/backups/* /Turenas/Work/Gitlab
echo "完成备份文件移动任务"
echo "开始清理多余的备份文件(清理N天以前)" bashpath=$(cd `dirname $0`; pwd) echo `find /Turenas/Work/Gitlab -maxdepth 1 -type f -mtime +4 | xargs rm -rf`
echo "脚本执行结束"
|