发牌SO 发表于 2018-1-11 16:36:23

GitLab 数据自动备份

  周期性计划任务:
  

crontab -e  

0 0 * * * /opt/gitlab/bin/gitlab-rake gitlab:backup:create  
service crond restart
  

  每天凌晨备份gitlab的数据
  删除过期的备份文件:
  因为每天都会进行一次备份,而备份的数据比较大,磁盘空间会被大量使用,因此,定期删除过期的文件
  

vim /var/opt/gitlab/backups/remove.sh  

  

!/bin/bash  

find "/var/opt/gitlab/backups/" -name ".tar" -ctime +1 -type f -exec rm -rf {} \;  
$contab
-e  

0 5 * * root /var/opt/gitlab/backups/remove.sh -D 1  
$service crond restart
  
每天凌晨5点执行删除过期文件的脚本,remove.sh会删除创建时间是一天前的文件
  
$
chmod +x remove.sh  
赋予脚本执行权限,否则用户不能执行此脚本.
  

  

  

  


页: [1]
查看完整版本: GitLab 数据自动备份