rsync自动备份配置

自动备份配置

方案:

采用gitlab备份方案备份配置信息、rsync远程同步版本库信息,以及生成的配置信息。(每天凌晨两点备份)

线上机备份机都安装 rsync:
yum install rsync

开放防火墙873端口

firewall-cmd --zone=public --add-port=873/tcp --permanent
firewall-cmd --reload

备份模式:

备份机做服务器、线上机做客户端

1)服务端(备份机器)配置:

mkdir /etc/rsyncd
创建主配置文件
vim /etc/rsyncd/rsyncd.conf

port = 873
pid file = /etc/rsyncd/rsyncd.pid
motd file= /etc/rsyncd/welcome.msg
lock file = /etc/rsyncd/rsyncd.lock
log file = /etc/rsyncd/rsyncd.log
timeout = 900

#配置某些格式不压缩
dont compress   = *.gz *.tgz *.zip *.z *.Z *.rpm *.deb *.bz2

[backup]
#服务器读写目录
path = /data/gitlab
comment = gitlab backup path
use chroot = no
#只写选择,只让客户端到服务器上写入
write only = yes
#只读选择,只让客户端从服务器上读取文件
read only = no
max connections = 5
list = yes
uid = root
gid = root
secrets file = /etc/rsyncd/rsyncd.secrets
#允许客户端连接IP地址
hosts allow = 192.168.143.36
hosts deny = *
ignore errors = yes
transfer logging = yes
log format = %t %a %m %f %b
auth users = gitlab

创建用户信息配置文件
vim /etc/rsyncd/rsyncd.secrets

gitlab:gitlab

chmod 600 /etc/rsyncd/rsyncd.secrets

启动服务
rsync --daemon --config=/etc/rsyncd/rsyncd.conf

停止服务
kill `cat /etc/rsyncd/rsyncd.pid`

2)客户端(线上机器)配置:

创建用户信息配置文件
vim /etc/rsyncd/rsyncd.secrets

gitlab #只保留密码

chmod 600 /etc/rsyncd/rsyncd.secrets

上传整个目录(写)

rsync -avzP--delete --progress --port=873 --password-file=/etc/rsyncd/rsyncd.secrets /data/gitlab/ [email protected]::backup

拉去整个目录(读)修改write only、read only

rsync -avzP--delete --progress --port=873 --password-file=/etc/rsyncd/rsyncd.secrets [email protected]::backup /data/gitlab/

你可能感兴趣的:(gitlab安装部署)