UnixServerAdmin

Server Administration & Management

How to Backup & Restore SVN Server

1. Create SVN Repository

# svnadmin create /path/to/reponame

2. Backup SVN Repository

# svnadmin dump /path/to/reponame > /backup/reponame.dump

3. If your svn repo is too large, you can use gzip to compress it during the backup:-

# svnadmin dump /path/to/reponame | gzip > reponame.dump.gz

4. To extract gzip file, use the command below:-

# gunzip reponame.svndump.gz

=======================================================

SVN through SSH will transfer your files in encrypted format over the network. If u using remote svn server then you can use svn over ssh.
By using SVN through SSH, you can avoid others from reading your source code. To SVN through SSH in Linux or Mac, follow the steps below:-

1. Start your terminal, Use the command below to checkout from the svn through ssh :-

# svn co svn+ssh://username@mysvnserver.com//home/svn/reponame /your/dest/folder

Note:- you need to change the above command variable to yours (eg. username, mysvnserver.com, repo directory and destination folder)
Once checkout, whenever you commit changes, the svn will be through ssh.

September 14, 2011 Posted by | SVN | , , | Leave a comment

How to Install & Configure SVN Server

SVN (Subversion) :- Subversion is a free/open-source version control system. Subversion manages files and directories, and the changes made to them, over time. This allows you to recover older versions of your data, or examine the history of how your data changed. In this regard, many people think of a version control system as a sort of “time machine”.

1. Install needed packages (mod_dav_svn and subversion)

# yum install mod_dav_svn subversion

2. Modify Subversion config file /etc/httpd/conf.d/subversion.conf

# /etc/httpd/conf.d/subversion.conf

Add following config to /etc/httpd/conf.d/subversion.conf file:
=======================================================
LoadModule dav_svn_module     modules/mod_dav_svn.so
LoadModule authz_svn_module   modules/mod_authz_svn.so

<Location /svn>
   DAV svn
   SVNParentPath /var/www/svn
   AuthType Basic
   AuthName “Subversion Repositories”
   AuthUserFile /etc/svn-auth-users
   Require valid-user
</Location>
=======================================================

Add AuthzSVNAccessFile row to subversion server config

AuthzSVNAccessFile /etc/svn-access-control

Finally /etc/httpd/conf.d/subversion.conf file should look something like following:

=======================================================
LoadModule dav_svn_module     modules/mod_dav_svn.so
LoadModule authz_svn_module   modules/mod_authz_svn.so

<Location /svn>
   DAV svn
   SVNParentPath /var/www/svn
   AuthType Basic
   AuthName “Subversion repositories”
   AuthUserFile /etc/svn-auth-users
   AuthzSVNAccessFile /etc/svn-access-control
   Require valid-user
</Location>
=======================================================

3. Add SVN (Subversion) users, Use following command:

# htpasswd -cm /etc/svn-auth-users testuser1 [Create testuser1, also create new file]

# htpasswd -m /etc/svn-auth-users testuser2 [Create testuser2]

Note: Use exactly same file and path name as used on subversion.conf file. This example use /etc/svn-auth-users file.

4. Create SVN Access Control file as /etc/svn-access-control file

# touch /etc/svn-access-control

5. Open /etc/svn-access-control file with your favourite editor ##

#  vi /etc/svn-access-control

Add following type content to file:

=======================================================
[groups]
testgroup1 = testuser1, testuser2
testgroup2 = testuser3, testuser4, testuser5
testgroup3 = testuser6, testuser7

[/]
* = r
@testgroup1 = rw
testuser4 = rw

[testrepo:/]
@testgroup2 = rw
testuser6 = rw

[testrepo2:/unixserv
@testgroup3 = rw
testuser5 = rw

[testrepo2:/tags]
@testgroup3 = r
testuser5 = rw
=======================================================

6. Create and configure SVN repository

# mkdir /var/www/svn

# cd /var/www/svn

# svnadmin create testrepo

# chown -R apache.apache testrepo

# chcon -R -t httpd_sys_content_t /var/www/svn/testrepo [If SELinux is enable]

# chcon -R -t httpd_sys_rw_content_t /var/www/svn/testrepo [Following enables commits over http]

5. Configure repository

To disable anonymous access and enable access control add following rows to testrepo/conf/svnserve.conf file:

anon-access = none [Disable anonymous access]

authz-db = authz [Enable access control]

8. Restart Apache Web Server

# /etc/init.d/httpd restart “OR”

# service httpd restart

September 13, 2011 Posted by | SVN | , , | Leave a comment