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
```