On nfs server:
Add line to /etc/exports
:
/backups/gitlab 10.10.10.10(rw,async,no_subtree_check,no_root_squash)
Reexport shares:
exportfs -rav
On gitlab server
Add line to /etc/fstab
:
nfs.srv:/backups/gitlab /mnt/backups/gitlab nfs4 rw,sec=sys 0 0
Install dependencies and mount nfs share:
yum -y install nfs-utils
mkdir -p -m 777 /mnt/backups/gitlab
mount -a
Configure /home/git/gitlab/config/gitlab.yml
:
...
## Backup settings
backup:
path: "tmp/backups" # Relative paths are relative to Rails.root (default: tmp/backups/)
keep_time: 604800
upload:
connection:
provider: Local
local_root: '/mnt/backups/gitlab'
remote_directory: 'daily'
...
Add cron job, create file /etc/cron.d/gitlab
:
# Create a full backup of the GitLab repositories and SQL database every day at 4am
# https://docs.gitlab.com/ce/raketasks/backup_restore.html
# Manual run: sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production STRATEGY=copy SKIP=builds,artifacts,registry DIRECTORY=daily
0 4 * * * git cd /home/git/gitlab && PATH=/usr/local/bin:/usr/bin:/bin bundle exec rake gitlab:backup:create RAILS_ENV=production CRON=1 STRATEGY=copy SKIP=builds,artifacts,registry DIRECTORY=daily