1,挂载NAS共享目录。编辑 /etc/fstab,添加一行:\\nas’s IP\share-dir /mnt/backups cifs credentials=/home/user/Download/secret.txt,uid=git,git=git 0 0
secret.txt添加如下信息:
username=
password=
之后mount -a手动挂载,之后会因为写入到了fstab而自动挂载
2,修改Gitlab备份路径。编辑 /etc/gitlab/gitlab.rb 文件,添加如下内容 (https://docs.gitlab.com/ee/raketasks/backup_restore.html#specifying-a-custom-directory-for-backups):
gitlab_rails['backup_upload_connection'] = {
:provider => 'Local',
:local_root => '/mnt/backups'
}
# The directory inside the mounted folder to copy backups to
# Use '.' to store them in the root directory
gitlab_rails['backup_upload_remote_directory'] = 'gitlab_backups'
gitlab_rails['backup_archive_permissions'] = 0644 # Makes the backup archives world-readable
# limit backup lifetime to 7 days - 604800 seconds
gitlab_rails['backup_keep_time'] = 604800
sudo gitlab-ctl reconfigure
3. 使用Crontab执行自动备份。注意12.0版本以下的备份命令和12.0版本以上的不同。
sudo su -
crontab -e
或者:sudo crontab -e
0 2 * * * /opt/gitlab/bin/gitlab-rake gitlab:backup:create CRON=1
参考文档:https://hisoka0917.github.io/git/2017/12/19/gitlab-backup/