SVN是subversion的缩写,是一个开放源代码的版本控制系统。
## 服务器端配置
安装SVN
```
yum install subversion -y
svnserve --version
```
创建第一个仓库(默认主路径为/var/svn)
```
mkdir -p /var/svn/repo1
svnadmin create /var/svn/repo1
```
修改配置文件vi /var/svn/repo1/conf/passwd
```
# Add below user account
admin01 = 123456
admin02 = 123456
user01 = 123456
user02 = 123456
```
修改配置文件vi /var/svn/repo1/conf/authz
```
# Add below
[groups]
administrators = admin01,admin02
users = user01,user02
[/]
@administrators = rw
@users = r
* =
```
修改配置文件vi /var/svn/repo1/conf/svnserve.conf
```
# Make sure below active
anon-access=none
auth-access=write
password-db=passwd
authz-db=authz
```
启动svn
```
svnserve -d -r /var/svn
ps -aux | grep svnserve
```
更好的自动服务模式
```
cat /etc/sysconfig/svnserve
# 默认为/var/svn,如果仓库创建在其他目录,这里需要相应修改
OPTIONS="-r /var/svn"
# 启动服务,并设为开机自动运行
systemctl start svnserve
systemctl enabe lsvnserve
systemctl status svnserve
```
查询socket statistics状态
```
ss -antp | grep svnserve
```
设置防火墙例外
```
firewall-cmd --permanent --add-port=3690/tcp
firewall-cmd --reload
firewall-cmd --list-ports
```
报错1:Can't open file '/svn/repos/format': Permission denied
可以临时关闭SELINUX
```
setenforce 0
getenforce
```
备份
```
svnadmin dump /svn/repos > /backup/repos-$(date +%Y%m%d).dump
```
恢复
```
svnadmin create /svn/repos
svnadmin load /svn/repos < /backup/repos-xxxxxxxx.dump
```
Hotcopy备份与恢复
```
svnadmin hotcopy /svn/repos /backup/repos-hotcopy-$(date +%Y%m%d)
svnadmin hotcopy /backup/repos-hotcopy-xxxxxxxx /svn/repos
```
Hotcopy参考
Can't I just use a hotcopy to restore the repository?
It depends, hotcopies created with svnadmin hotcopy must be moved to a server with identical setup. You should have the same version of subversion installed on both servers, same operating system, etc.
Subversion dumps are designed to work with different versions of subversion, and are just more flexible. Hotcopies are handy to have, but I recommend creating both hotcopies and dumps as part of your backup plan.
## 客户端配置
Windows系统安装TortoiseSVN
```
URL地址为svn://xxx.xxx.xxx.xxx/repo1
```
Linux系统
```
yum install subversion -y
mkdir /svn_repo1
svn checkout svn://xxx.xxx.xxx.xxx/repo1 /svn_repo1 --username=admin01
svn add a.c
svn commit -m "add a.c"
svn status
```