009 Installation and configuration of SVN under Linux (CentOS 6.8)

Subversion (SVN) is an open source version control system that manages data that changes over time.
This data is placed in a central repository, much like an ordinary file server,
that remembers every change to a file, so that it is possible to restore the file to an older version, or browse the change history of the file .


Contents of this article:
Linux svn server deployment
linux svn client command operation
linux svn backup and recovery




1. Linux svn server deployment


1. Install svn
# rpm -qa | grep subversion
# rpm -e --nodeps Name of JDK to uninstall
# yum install -y subversion
# svnserve --version
svnserve, version 1.6.11 (r934486) 


2. Create SVN repository
# mkdir -p /data/svn
# svnadmin create /data/svn/project
# ls /data/svn/project/
conf db format hooks locks README.txt 


3. Configure SVN
# cd /data/svn/project/conf/
# ls
authz passwd svnserve.conf


file description:
1) svnserve.conf: svn service configuration file.
2) passwd: Username password file.
3) authz: ​​svn rights profile.


svnserve.conf file
The configuration items in this file are divided into the following five items:
anon-access: Controls the permission of non-authenticated users to access the repository.
auth-access: Controls the permissions of authenticated users to access the repository.
password-db: Specifies the username and password filename.
authz-db: Specifies the name of the rights configuration file through which path-based access control can be implemented.
realm: Specifies the authentication realm of the repository, that is, the authentication realm name prompted when logging in. If the authentication domains of the two repositories are the same, it is recommended to use the same username and password data file 


to open the comment without leaving a space in front of it, otherwise there may be problems. Remember to change the realm in the last line to your svn directory, and the
configuration is as follows:
# grep -E "anon-access=|auth-access=|password-db=|authz-db=|realm=" svnserve.conf  
anon-access=none  
auth-access=write 
password-db=passwd  
authz-db=authz  
realm = /data/svn/project 


passwd
file is used to configure username and password
# cat passwd
[users]
Admin = 123456
boco = 123456
testR = 123456
testRW = 123456
testNoRW = 123456


authz file
Format description:
repository directory format:
[<version library>:/project/directory]
@<usergroupname>=<permission>
<username>=<permission>


Configure user access rights
# cat authz |grep -v '#' 
[aliases] 
[groups] 
project_rw=Admin
project_r =testR,boco


[/]
@project_rw=rw
@project_r=r
boco=rw
testRW=rw
testNoRW=
*=


[/doc]
@project_rw=rw
@project_r=r
*=


Note:
rw read/write
r read
empty without permission
* Other users




4. Start, stop, view svn service
View :
ps -ef|grep svnserve
netstat -ntlp | grep svn
start:
# svnserve -d -r /data/svn /project --listen-port 4000
Stop:
# killall svnserve


5. Test login
Open the Repository Browser of the TortoiseSVN software
and enter: svn://192.168.10.240:4000 in the pop-up menu, click OK
to enter the account and password to log in, the user is case-sensitive




2. Linux svn client command operation
1. Checkout the file to the local directory
svn checkout path (path is the directory on the server)
Shorthand: svn co
Example:
# svn co svn://192.168.10.240:4000/ --username= boco --password=123456
# svn co svn://192.168.10.240:4000/doc --username=boco --password=123456
Specify the version of the file 
# svn co svn://192.168.10.240:4000/ --username=boco --password=123456 -r 5 


2. Add a new file to the local repository
svn add file (this command must be checked out It can only be operated in the path that comes out)
For example:
# cp /root/123.txt ./Add
123.txt to the local library
# svn add 123.txt
A 123.txt 


3. Submit the changed files to the repository
svn commit -m "LogMessage" [-N] [--no-unlock] PATH (if locking is selected, use the --no-unlock switch) 
Shorthand: svn ci
Example:
only commit 123.txt
# svn commit 123.txt -m 'add 123.txt' 
submits all files in the current directory by default 
# svn commit -m 'add 123.txt'  
can also be a regular matching file submission 
# svn commit *.txt -m 'add 123.txt'  


4. Add lock/unlock
svn lock -m "LockMessage" [--force] PATH 
example:
# svn lock -m "lock test file" test.PHP 
# svn unlock PATH 


5. Update to a certain version
svn update -rm path
abbreviation: svn up
For example:
if there is no directory behind, the default will be the current directory and all subdirectories The files are updated to the latest version.
# svn update
restores the file test.php in the repository to version 200
# svn update -r 200 test.php
is updated and synchronized with the repository. If the prompt is expired when submitting, it is because of conflict,
you need to update first, modify the file, then clear svn resolved, and finally submit commit
# svn update test.php


6. Delete the file
svn delete path -m "delete test fle"
shorthand : svn (del, remove, rm)
For example:
# svn delete svn://192.168.1.1/pro/domain/test.php -m "delete testfile"
or directly svn delete test.php and then svn ci -m 'delete testfile', it is recommended to use this


7. View the log
svn log path
For example: svn log test.php displays all the modification records of this file and the changes of the version number 


8. View the file details
svn infopath
For example: svn info test.php #You can know the path version, time, submitter and other information 


9. Compare differences
svn diff path (compare the modified file with the base version)
Shorthand: svn di 
Example: svn diff test.php
svn diff -rm:n path (compare the differences between version m and version n)
Example: svn diff -r 200 :201 test.php #You can know what has been modified


10. Merge the differences between the two versions into the current file
svn merge -rm:n path 
For example: svn merge -r 200:205 test.php (combining version 200 with The differences between 205 and 205 are merged into the current file, but there will generally be conflicts, which need to be dealt with)


11. SVN help
svn help
svn help ci   


12. List of files and directories under the
repository svn list path #Display all files in the path directory that belong to Repository files and directories
Shorthand  : svn ls


13. Create a new directory under version control
svn mkdir #Create a new directory under version control.
usage:
svn mkdirPATH #The effect is the same: mkdir test;svn add test; 


14. Restore local modifications
svn revert: restore the original unchanged working copy files (restore most of the local modifications).
revert:
Usage: revert PATH...
Note: This subcommand does not access the network and resolves conflicts. But it will not restore the deleted directory 






3. Linux svn backup and recovery


1. Full backup:
here is the latest version of the query project directory
curr=`svnlook youngest /data/svn/project/` 
svnadmin dump /data/svn/ repos/test --revision 0:$curr --incremental >0-"$curr"svn.bak  
echo $curr >/tmp/svn_revision 


2. Incremental backup
old=`cat /tmp/svn_revision`
new=`svnlook youngest /data/svn/project/` 
svnadmin dump /data/svn/repos/test --revision $old:$new --incremental >$old"-"$new"svn.bak 


3. svn restore
restore order from lower version Restore to higher versions one by one; that is, restore the most recent full backup first, then restore the incremental backup next to this file.
cd /data/svn/repos/  
svnadmin create test2  
svnadmin load test2 < /data/svnback/20110719/0-1112svn.bak  
svnadmin load test2 < /data/svnback/20110719/1113-1120svn.bak 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324954558&siteId=291194637