有什么网站做微商,网站流量统计软件,土木工程网官网首页,黑科技引流推广神器GitLab定时备份 文章目录 GitLab定时备份GitLab基础环境备份命令自动清理备份上传命令设置定时任务参考链接 GitLab基础环境
部署方式#xff1a;Docker
版本#xff1a;16.2.2
备份命令
Notes#xff1a;
编写sh脚本时#xff0c;不要使用Windows上的Notepad类似编辑…GitLab定时备份 文章目录 GitLab定时备份GitLab基础环境备份命令自动清理备份上传命令设置定时任务参考链接 GitLab基础环境
部署方式Docker
版本16.2.2
备份命令
Notes
编写sh脚本时不要使用Windows上的Notepad类似编辑器执行时可能会出现语法错误直接通过touch和vim命令编辑即可注意赋予可执行权限chmod x gitlab_backup.sh
gitlab_backup.sh
#! /bin/bash
docker exec gitlab gitlab-rake gitlab:backup:create自动清理备份
gitlab_delete.sh
#! /bin/bash
find /home/data/apps/gitlab/data/backups/ -type f -mtime 7 -name *.tar -exec rm -rf {} \;寻找并删除 /home/data/apps/gitlab/data/backups/目录下内容修改时间mtime为7天以前的tar文件-type f并删除rm -rf 上传命令
备份后需要将文件传送至其他服务器。
Notes
通过scp命令实现远程复制可以设置ssh公钥实现免密登录远端服务器设置步骤参考最后链接。复制前要保证远端服务器已经存在指定的目录
gitlab_upload.sh
#! /bin/bash
backdir/home/data/apps/gitlab/data/backups
latestFileNamels $backdir -t|head -n 1
cd $backdir
scp $latestFileName root172.xxx.xxx.xx:/data/apps/gitlab/backups
ssh root172.xxx.xxx.xx find /data/apps/gitlab/backups -type f -mtime 7 -exec rm -f {} \;设置定时任务
crontab -e10 0 * * * /data/gitlab/cron/gitlab_backup.sh /tmp/cron.log 21
20 0 * * * /data/gitlab/cron/gitlab_upload.sh /tmp/cron.log 21
30 0 * * * /data/gitlab/cron/gitlab_delete.sh /tmp/cron.log 21每天的零点10分自动备份零点20分自动将最新备份文件上传至远端服务器零点30分自动删除7天前的备份 参考链接
docker部署GitLab配置本机自动备份、自动清理gitlab定时备份linux添加ssh公钥免密登录