Archive for August, 2013

SVN Deployement:

1. Checkout the repository and commit the project files on client side:

To check out the repository:
This can be done any path in the server. It creates a working copy under the path where you run below command.

~]# cd /usr/local/src/
~]# svn co http://localhost/svn/project

It downloads entire repository.
If we make any changes to project files that can’t be reflected to directly at the repository. So we need to commit the files to make it effect on repository.
For suppose:
Go the project directory:
~]# cd /usr/local/src/svn/project

I have 2 files in this path
f1 and f2
I would like to edit the file f1

~]# vi f1
Added below line to this file and saved in my case…
SVN deployemnt

At this moment if we check the svn repo url it cant shows the changes we made to the project file.
So, to reflect the changes, we need to commit

Go to the working copy
~]# cd /usr/local/src/svn/project

Run below command…
~]# svn commit -m “edit for file f1” (Format: option ‘m’ is for messages which is quoted)
Now check the url…
At this moment. it shows the changes what we made to file f1.

These commits reflects svn repo url only,
But if we have the application and want to reflect the changes in application then follow below steps
Go to the working copy:
~]# cd /usr/local/src/svn/
~]# svn status -u
~]# svn update
Then restart the webserver(apache in my case) services and check the application…

2. Revert or rollback the changes:

  • This for one revision to any other revision numbers…

~]# svn merge -r 5:4 .
It reverts the revision number 5 to revision number 4
Format: higher higher revison:lower revision
Need not be in order but higher to lower works
ex: svn merge -r 10:5 works

Then run below command to rollback the changes
~]# svn commit -m “Rolled back”
~]# svn update

Now check the url.

  •  To revert the perticular revision, run below command…

~]# svn update -r8 (Format: svn update -r revisionnumber)

 SVN backup and Restore…

1.  With in the system or server…

To take the backup of repository…

~]# svnadmin dump /var/www/svn/repos | gzip -9 > /var/www/svn/repos.dump.gz

Restore Process:

Extract the dump file…

~]# gunzip repos.dump.gz

Create the repos directory at SVN path… 
~]# svnadmin create /var/www/svn/repos

To restore…
svnadmin load /var/www/svn/repos < /var/www/svn/repos.dump

Restart apache services and check the url…


2. To restore in other server

we need to copy below files from existing server…

1. Dump of the svn repository
2. /etc/httpd/svn_access_control
3. /etc/httpd/svn_users_passwd

Note: Copy svn_access_control and svn_users_passwd to /etc/httpd

After copying these files, follow the restore process same as above.


Install subversion and mod_dav_svn…
~]# yum install subversion
~]# yum install mod_dav_svn
~]# vi /etc/httpd/conf.d/subversion.conf
Add below line to subversion.conf…

<Location /svn>
DAV svn
SVNPath /var/www/svn/repos
AuthType Basic
AuthName “Subversion Repository”
AuthUserFile /etc/httpd/svn_users_passwd
AuthzSVNAccessFile /etc/httpd/svn_access_control
Require valid-user

Now create a repos directory at the svn path…

~]# mkdir /var/www/svn/
~]# cd /var/www/svn/
svn]# svnadmin create repos
svn]# svnadmin create repos
svn]# cd repos/

Create a default user for to access the entire repository…
repos]# htpasswd -cm /etc/httpd/svn_users_passwd admin

Add this user to svn_access_control
repos]# vi /etc/httpd/svn_access_control
Add below lines to svn_access_control file…

admin = rw

Restart apache services…
~]# /etc/init.d/httpd restart

Now test the url…
Username: admin

Project creation under this repository:


~]# cd /tmp/
~]# mkdir project (Format: mkdir projectname)
~]# touch project/f1
~]# touch project/f2

Change the ownership of svn path to apache…
]# chown apache:apache /var/www/svn/repos/ -R

Import the project to repository…
~]# svn import -m “My 1st project” project/ http://localhost/svn/project (“any thing can write on quoted”)

Create a user for project…
~]# htpasswd -m /etc/httpd/svn_users_passwd user1

Add this use info at svn_access_control file…
~]# vi /etc/httpd/svn_access_control

project = rw
~]# /etc/init.d/httpd restart

Username: user1

Project2 creation…

~]# mkdir webportal
~]# touch webportal/web1
~]# touch webportal/web2
~]# touch webportal/web3

~]# svn import -m “My 1st project” webportal/ http://localhost/svn/webportal

~]# htpasswd -m /etc/httpd/svn_users_passwd user2
~]# vi /etc/httpd/svn_access_control

user2 = rw

~]# /etc/init.d/httpd restart

Now check the url…
Username: user2

Adding groups to svn_access_control to enable additional users and existed users to access the projects

Add below line under admin user definition…
vi /etc/httpd/svn_access_control
project = user1, user2

When you add users for project group, then project definition must be as follows…

@project = rw (Format: @groupname =rw )

~]# /etc/init.d/httpd restart
Now user1&2 can access project

To add extra user user3 to the project group… 
~]# htpasswd -m /etc/httpd/svn_users_passwd user3

Then add this user to already existed group…

project = user1. user2. user3

~]# /etc/init.d/httpd restart

Now test the project project with http://localhost/svn/project
Now user1&2&3 can access project