SVN centralized Version Control Software

Source: Internet
Author: User

SVN centralized Version Control Software

Introduction:

Currently, in popular version control software, SVN (centralized Version Control) is a widely used version that has been used earlier. Now git (distributed version control) is more popular.

SVN documents written earlier are lost, which is easy to organize.

I. Install SVN (CentOS)

Shell> yum-y install subversion

Shell> svn -- version -- quiet # version number
1.6.11

Ii. SVN basic steps

1. Create a working directory and version Library

 

Shell> mkdir/svn # create a working directory (which can be omitted)
Shell> svnadmin create/svn/myrepos # create a version library named myrepos (you can use svnadmin help [subcommands] command parameters)

Shell> ls/svn/myrepos/# directories and files in the version Library
Conf db format hooks locks README.txt

Shell> tree/svn/myrepos/conf/# version library configuration file directory
/Svn/myrepos/conf/
── Authz # user authorization
├ ── Passwd # User Authentication
── Svnserve. conf # svnserve service configuration file

 

2. Modify the SVN version library configuration file (you need to restart svnserve)

 

Shell> grep-vP '^ # | ^ $'/svn/myrepos/conf/svnserve. conf # No space at the beginning of the file line
[General]

Anon-access = none # anonymous user access permission
Auth-access = write # authenticate the user's access permission
Password-db = passwd # authenticate the User password File
Authz-db = authz # directory authorization File Location
Realm = My First Repository # prompt information

[Sasl]

 

3. Add an authenticated user and password (username = password)

Shell> grep-vP '^ # | ^ $'/svn/myrepos/conf/passwd
[Users]

Wang = wang_pwd
Guaishou = guaishou_pwd

4. Add directory authorization

 

Shell> grep-vP '^ # | ^ $'/svn/myrepos/conf/authz
[Aliases]

[Groups]

[Myrepos:/] # authorization directory

Wang = rw # authorized Authenticated Users (readable and writable)

* = # Unauthorized Authenticated Users (not authorized)

 

5. Start SVN as a daemon

Shell> svnserve-d-r/svn #-d start a svnserve as a daemon, and-r specifies the version Library

# Listening to TCP port 3690 by default. When starting in daemon mode, you can use -- list-port and -- list-host to specify the port and host

Shell> netstat-lnpt | grep 3690
Tcp 0 0 0.0.0.0: 3690 0.0.0.0: * LISTEN 1883/svnserve

6. Authorization test (1)

Shell> svn checkout -- no-auth-cache -- username wang -- password wang_pwd svn: // 192.168.12.128/myrepos/home/wang/myrepos # Success
Obtain version 0.

Shell> svn co -- no-auth-cache -- username guaishou -- password guaishou_pwd svn: // 192.168.12.128/myrepos/home/guaishou/myrepos # failure (co = checkout)
Svn: authentication failed

# It can be seen from the above that the authorization in authz takes effect (User: guaishou is also an authenticated user but not authorized)

 

Shell> touch/home/wang/myrepos/readme # create a test file
Shell> svn add/home/guaishou/myrepos/readme # add to work zone
Shell> svn -- no-auth-cache -- username wang -- password wang_pwd commit-m 'add readme '/home/guaishou/myrepos/readme # commit submit,-m specifies log
Added home/wang/myrepos/readme
Transfer file data.
The submitted version is 1.

 

# It can be seen from the above that the user: wang's authorized read and write permissions take effect.

 

Shell> grep-vP '^ # | ^ $'/svn/myrepos/conf/authz
[Aliases]

[Groups]

[Myrepos:/]

Wang = rw

* = R # unauthorized Authenticated Users (read-only permission)

Shell> svn co -- no-auth-cache -- username guaishou -- password guaishou_pwd svn: // 192.168.12.128/myrepos/home/guaishou/myrepos # Success
A/home/guaishou/myrepos/readme
Obtain version 1.

Shell> echo my name is guaishou>/home/guaishou/myrepos/readme # modify readme
Shell> svn -- no-auth-cache -- username guaishou -- password guaishou_pwd commit-m 'change readme '/home/guaishou/myrepos/readme # failure (User: guaishou is read-only)
Svn: submission failed (details are as follows ):
Svn: authentication failed

 

# As we can see from the above, the authz file is changed and takes effect without restarting svnserve.

7. Authorization test (2)

 

Shell> mkdir/home/wang/myrepos/{home_f, home_g, public} # create three test Directories

Shell> svn add/home/wang/myrepos/* # add to work zone
A/home/wang/myrepos/home_f
A/home/wang/myrepos/home_g
A/home/wang/myrepos/public
Svn: Warning: "/home/wang/myrepos/readme" has been included in version control.

Shell> svn -- no-auth-cache -- username wang -- password wang_pwd commit-m'add test dir'/home/wang/myrepos/# submit to version Library
Add home/wang/myrepos/home_f
Add home/wang/myrepos/home_g
Added home/wang/myrepos/public
The submitted version is 2.

Shell> grep-vP '^ # | ^ $'/svn/myrepos/conf/passwd # Add Authenticated Users
[Users]

Wang = wang_pwd
Feng = feng_pwd
Guaishou = guaishou_pwd

Shell> grep-vP '^ # | ^ $'/svn/myrepos/conf/authz # The new authorization directory is as follows:
[Aliases]

[Groups]

[Myrepos:/]

Wang = rw

* = R

[Myrepos:/home_f]

Wang = r
Feng = rw

* =

[Myrepos:/home_g]

Wang = r
Guaishou = rw

* =

[Myrepos:/public]

* = Rw

Shell> svn co -- no-auth-cache -- username wang -- password wang_pwd svn: // 192.168.12.128/myrepos/home/wang/myrepos/# wang detected all directories
A/home/wang/myrepos/home_f
A/home/wang/myrepos/readme
A/home/wang/myrepos/home_g
A/home/wang/myrepos/public
Obtain version 2.

Shell> svn co -- no-auth-cache -- username feng -- password feng_pwd svn: // 192.168.12.128/myrepos/home/feng/myrepos/# home_g is not detected in feng
A/home/feng/myrepos/home_f
A/home/feng/myrepos/readme
A/home/feng/myrepos/public
Obtain version 2.

Shell> svn co -- no-auth-cache -- username guaishou -- password guaishou_pwd svn: // 192.168.12.128/myrepos/home/guaishou/myrepos/# home_f is not detected in guaishou
A/home/guaishou/myrepos/readme
A/home/guaishou/myrepos/home_g
A/home/guaishou/myrepos/public
Obtain version 2.

Shell> touch/home/wang/myrepos/home_f/readme # create a test file

Shell> svn add/home/feng/myrepos/home_f/readme # add to Workspace
A/home/wang/myrepos/home_f/readme

Shell> svn -- no-auth-cache -- username wang -- password wang_pwd commit-m'add readme '/home/feng/myrepos/home_f/readme # submission failed
Added home/wang/myrepos/home_f/readme
File data transfer. svn: submission failed (details are as follows ):
Svn: Access denied

Shell> touch/home/wang/myrepos/public/readme

Shell> svn add/home/wang/myrepos/public/readme
A/home/wang/myrepos/public/readme

Shell> svn -- no-auth-cache -- username wang -- password wang_pwd commit-m'add public/readme '/home/wang/myrepos/public/readme # submission successful
Added home/wang/myrepos/public/readme
Transfer file data.
The submitted version is 3.

 

# All right, authorization is here!

3. Stop svnserve

Shell> kill $ (ps aux | grep svnserve | grep-v grep | awk '{print $2 }')

4. SVN backup and restoration (write a small script and add it to the task plan !)

1. Logical backup (Flexible backup, full backup, incremental backup-incremental, space saving, suitable for a small version Library)

Shell> svnadmin dump/svn/myrepos>/data/backup/svn/myrepos _ $ (date + % Y % m % d). bak

2. Physical backup (large space occupation, fast backup and recovery)

Shell> svnadmin hotcopy/svn/myrepos/data/backup/svn/myrepos_hot _ $ (date + % Y % m % d). bak

3. Logical Restoration

Shell> svnadmin load/svn/myrepos/</data/backup/svn/myrepos_20160303.bak # Note: if the version library is deleted, You need to reconfigure the authenticated user and authorize it after restoration!

4. physical restoration

Shell> svnadmin hotcopy/data/backup/svn/myrepos_hot_20160303.bak // svn/myrepos # The path is exactly the opposite!

V. Win Client Connection

Shell> iptables-a input-p tcp -- dport 3690-j ACCEPT # Open TCP port 3690
Shell> service iptables save

1. Download and install TortoiseSVN)

2. Create a working directory, right-click Checkout --> URL (svn: // 192.168.12.128/myrepos) --> enter the user name and password (wang/wang_pwd)

3. Test authorization, create a file, add and submit the file, and check whether the authorization is correct!

# First come here!

Set up SVN server SVN in Ubuntu 14.04 ://

CentOS 6.2 SVN setup (YUM installation)

Deploy Apache + SVN in CentOS 6.5

Build an SVN server using Apache + SVN

Set up and use the SVN server in Windows + reset the password on the client

Install SVN in Ubuntu Server 12.04 and migrate Virtual SVN data

Build SVN service and migration method on Ubuntu Server

Subversion (SVN) Details: click here
Subversion (SVN): click here

This article permanently updates the link address:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.