gitlab 备份

gitlab 备份

gitlab-rake gitlab:backup:create 

执行之后,就会生成一个备份文件

[root@iZuf6dztc469onegfborf5Z backups]# ll
-rw------- 1 git git 1361940480 11月  6 16:43 1541493776_2018_11_06_11.1.4_gitlab_backup.tar

可以写一个脚本

#!/bin/bash
cd /var/opt/gitlab/backups/
gitlab-rake gitlab:backup:create  
find  /var/opt/gitlab/backups/  -type f -ctime +5 -exec rm -rf {} \;

进入文件夹,进行备份。查找五天前的备份数据,进行删除。
备份可以安排在每天的3点30左右。这个时候大家都睡觉。

# echo "30 03 * * * root run-parts /home/jiqing/sh >> /tmp/git_backup.log 2>&1" >>  /etc/crontab
/sbin/service crond stop
/sbin/service crond start

重启定时服务。

Linux下的任务调度分为两类,系统任务调度和用户任务调度

  • 系统任务调度:系统需要定期执行的任务,比如重启、日志清理等,其配置文件是:/etc/crontab。
  • 用户任务调度:某个用户需要定期执行的任务。用户可以使用 crontab 命令来配置自己的定时任务。所有用户配置的定时任务都存放在 /var/spool/cron/ 目录下,其文件名与用户名一致。如:root用户的所有定时任务就保存在 /var/spool/cron/root 文件中。

猜你喜欢

转载自www.cnblogs.com/jiqing9006/p/9916835.html