You are here
Home > LinuxAdmin >

How To Install SVN Server On Ubuntu 18.04

In every software project there is need for version control system. Here we will list out steps for install SVN server on Ubuntu machine.

Install Apache

sudo apt-get update

sudo apt-get install apache2

sudo systemctl start apache2

Contents

Install Apache Subversion

sudo apt-get install subversion libapache2-mod-svn

sudo apachectl -M

sudo a2enmod dav

sudo a2enmod dav_svn

sudo a2enmod authz_svn

sudo service apache2 restart

Create SVN Repository

Most common places for Subversion repository are: /srv/svn, /usr/local/svn and /home/svn. Here we will assume /home/svn as repository

sudo mkdir /home/svn

Create svn repository. Here we create a repository called “IEC1000”

sudo svnadmin create /home/svn/IEC1000

change ownership and permissions

sudo chown -R www-data:www-data /home/svn/IEC1000/

sudo chmod -R 775 /home/svn/IEC1000

If you are using windows system use "TortoiseSVN" to create repository and add files/folders to SVN. 

If you are using Linux system use "rabbit SVN" to create repository.

sudo apt-get install rabbitvcs-nautilus

Access via WebDAV protocol (http://)

First install the package libapache2-svn then add the following snippet in your /etc/apache2/mods-available/dav_svn.conf file:

<Location /svn>
DAV svn
SVNPath /home/svn/IEC1000
AuthType Basic
AuthName "myproject subversion repository"
AuthUserFile /etc/subversion/passwd
Require valid-user
</Location>
Create first user and passwd file using following command 
sudo htpasswd -cm /etc/subversion/passwd user_name1
create second user and onward using following command  
sudo htpasswd -m /etc/subversion/passwd user_name2

Restart Apache

sudo systemctl restart apache2

Now you can test configured SVN using local host with following URL on browser,

http://localhost/svn/IEC1000

Schedule Repository Backup

Create a backup folder.

sudo mkdir -p /etc/backcups

Change user to root user.

sudo su -

Edit crontab.

crontab -e

In the following command, we schedule svn backup midnight every day.

0 0 * * * svnadmin dump /home/svn/IEC100 > /etc/backcups/svnbackups-$(date +%Y%m%d).dump

If you need to restore svn repository from backup file use below commands.

Create a new repository.

svnadmin create /home/svn/restorerepo

Restore backup:

svnadmin load /home/svn/restorerepo < /etc/backups/svnbackups-20190204.dump

One thought on “How To Install SVN Server On Ubuntu 18.04

Leave a Reply

Top