简单的Gitlab备份脚本

目标:每日备份一次,然后上传至另外的服务器。

一、简单备份脚本

/home/tools/backup.sh:

/usr/bin/rm  /var/opt/gitlab/backups/* -rf
/opt/gitlab/bin/gitlab-rake gitlab:backup:create
/usr/bin/scp /var/opt/gitlab/backups/* root@192.168.3.179:/home/backups/gitlabs
/usr/bin/scp /etc/gitlab/gitlab.rb root@192.168.3.179:/home/backups/gitlabs/gitlab.rd.`date +%Y-%m-%d.%k%M%S`.rd
ssh root@192.168.3.179 find '/home/backups/gitlabs/' -mtime +3 -type f -exec 'rm -f {} \;'

 

二、定时任务

[root]# crontab -l
0	1	*	*	*	/usr/bin/bash /home/tools/backup.sh