docker安装的gitlab备份脚本
#!/bin/bash
#auto backup docker gitlab
#auther kim 2020.11.12
LogFile=/var/log/gitlab_backup.log
#备份gitlab
echo "------开始备份gitlab数据--------"
docker exec gitlab gitlab-rake gitlab:backup:create
if [ $? -eq 0 ];then
echo "-------------------gitlab backup Success!$(date +"%Y-%m-%d %H:%M:%S")---------------------" >> $LogFile
else
echo "-------------------gitlab backup failed! $(date +"%Y-%m-%d %H:%M:%S")---------------------" >> $LogFile
fi
mv /data/gitlab/data/backups/*.tar /data/backup/gitlab_bak/
#删除过期的备份文件
find /data/backup/gitlab_bak/ -name "*.tar" -mtime +4 -type f -exec rm -rf {} ;