close

使用Crontab去定時備份GitLab的資料到遠端的NFS Server (192.168.100.100:/backup/gitlab)

1. Check crond service.
# systemctl list-unit-files

2. 若crond.service是disabled,請將它enable,這樣OS啟動後才會自動執行
# systemctl enable crond.service

3. 手動啟動crond service
# systemctl start crond.service

4. 編輯crontab設定
# crontab -e

================================
50 1 * * * mount |grep "/backup/gitlab" > /dev/null;if [ "$?" -eq 1  ]; then mount -t nfs 192.168.100.100:/backup/gitlab /var/opt/gitlab/backups;fi
0 2 * * * /usr/bin/gitlab-rake gitlab:backup:create CRON=1
20 2 * * * ls -dt /var/opt/gitlab/backups/* | tail -n +15 | xargs rm -rf

================================

 

解說:
第一行:每天凌晨1點50分,去mount NFS 192.168.100.100的/backup/gitlab到GitLab本機的/var/opt/gitlab/backups
第二行:每天凌晨2點整,下GitLab的指令去備份資料到/var/opt/gitlab/backups
第三行:每天凌晨2點20份,去做Backup Rotation的檢查,這裡設定的是保14天(也就是14份)的GitLab backup data.

arrow
arrow
    全站熱搜

    dreamtails 發表在 痞客邦 留言(0) 人氣()