msgbartop
MAC OS X, Linux, Windows and other IT Tips and Tricks
msgbarbottom

08 Jun 15 Undeleting a directory from SVN repository

Situation:
A directory had been deleted a while ago from the repository and we want it back without interfering with commits that were since made in other parts of the repository, and without having to have the repository in the workspace.
Reference: http://svnbook.red-bean.com/en/1.8/svn.branchmerge.basicmerging.html#svn.branchmerge.basicmerging.undo

Solution:
– Find out which revision of the commit it was that deleted the directory and substract 1 of it.
– Use the copy command which copies the full content of a directory from back then and commit it now including the history of the directory.

Example:
Repo: myproject1
Directory to undelete: /code/interface1
Revision of the delete commit: 1264

Now we are going to copy the full content of the directory for a revision just before it got deleted. meaning using the revision 1263
Command:
svn copy -m 'Undeleting the /code/interface1' https://svn.company.com/code/interface1@1263 https://svn.company.com/code/interface1

Result:
Committed revision 1289
The deleted directory /code/interface1 should be back there where it was. It is done via a new commit without interfering with any subsequent commits in other parts of the repo including the diffs from history related to this directory.

12 Aug 11 Install a load balanced SVN system

Until I create my own docs here, I suggest you have a look at the following page from which I’m going to base my own version here anyway.

http://www.devx.com/opensource/Article/39525/1954

12 Aug 11 Rebuild a mirror SVN from a master repository

There are a few ways to create a mirror SVN repository from a master repository.
Some are slower than others but all of the ones mentioned below are reliable.

The standard way:
(All operations below are done on the mirror server)
– Delete the old mirror repository
– svnadmin create {path of repo}
– svnsync init {path of repo} {master URL}
– svnsync sync {path of repo}
– set file permissions of repo

Here is a small crude script which does this job. Please adapt to your needs.
############################################################
# Script to fully recreate a mirror repo from master repo
############################################################
repo="test-repo"
svndir="/home/svnadm/svn"
hooksskeldir="/home/svnadm/etc/skel/hooks_svn"
master="svn.mydomain.com"
repouser="svnadm"
syncuser="syncuser"
syncpass="secret"
# Deleting the old repo ${svndir}/${repo}
rm -rf ${svndir}/${repo}
#--------
# create the new repo
svnadmin create ${svndir}/${repo}
#--------
# replace hooks
rm ${svndir}/${repo}/hooks/*
cp -a ${hooksskeldir}/* ${svndir}/${repo}/hooks/
#--------
# Initialize the mirror repo from the master
svnsync init --source-username ${syncuser} --source-password ${syncpass} file://${svndir}/${repo} http://${master}/${repo}
#--------
# Synchronize the repo .... this can take a while
svnsync sync --source-username ${syncuser} --source-password ${syncpass} file://${svndir}/${repo}
#--------
# Set the file permission on the new created repository.
find ${svndir}/${repo}/ -type d -exec chmod 2775 '{}' \;
find ${svndir}/${repo}/ -type f -exec chmod g+w '{}' \;
chmod 444 ${svndir}/${repo}/format

The fast way:
(All operations below are done on the mirror server)
# Copy method (faster)
==============================
# Steps
– make an rsync to create a replica of the master repo
– do a very small adaptation to a special file in the mirror repo (telling where the master is)
– Replace the hooks scripts/files if needed
– Set the repos access rights
– The verify the mirror repo with svnsync
– If no errors occur, then that’s it.!

Some explanation:
There is absolutely no differences between the master and a mirror repo except!!!
the mirror repo MUST know where the master is (URL).
This information is located in this file in the mirror repo:
{repo-root-dir}/db/revprops/0/0
Each svn information in this file is covered by 2 lines of text:
First line: {Type}{Space}{Value}
Type:V=Value K=key
Space: the space character
Value: the number of characters the Info (located in the line following this one) contains.
Second line: Info needed

Example: Our interest here is to make sure the mirror has the info of URL of the svn master repo which is located on lines 7 and 8.
Line 7: V 38
Line 8: http://svn.example.com/test-repo

This means the URL on line 8 is a Value(V) of 38 characters long.
Adjust these 2 lines appropriately and save the file.

The same principle applies to all of the lines in this file.
I strongly recommend NOT to change any of the other lines unless you really know what you’re doing.

After that you only need to replace the hook scripts and set the repo file access rights(if needed) and then verify that the mirror repo is in sync with the master using svnsync command. If no output or some SVN items are being synchronized (which were committed during the rebuilding of the mirror repo) then all is OK, the mirror repo is healthy and in sync.

Here is a small crude script which does this job. Please adapt to your needs.
############################################################
# Script to fully recreate a mirror repo from master repo
############################################################
repo="test-repo"
svndir="/home/svnadm/svn"
hooksskeldir="/home/svnadm/etc/skel/hooks_svn"
master="svn.mydomain.com"
repouser="svnadm"
syncuser="syncuser"
syncpass="secret"
#--------
# Emptying the existing repo ${svndir}/${repo} on mirror
rm -rf ${svndir}/${repo}
mkdir ${svndir}/${repo}
#--------
# Transfering the repo from master to mirror
rsync -vazu ${repouser}@${master}:${svndir}/${repo}/ ${svndir}/${repo}/
#--------
# Change lines 7 and 8 in file ${svndir}/${repo}/db/revprops/0/0
URL="http://${master}/${repo}"
length=${#URL}
sed -i "7s|.*|V ${length}|" ${svndir}/${repo}/db/revprops/0/0
sed -i "8s|.*|$URL|" ${svndir}/${repo}/db/revprops/0/0
#--------
# replace hooks
rm ${svndir}/${repo}/hooks/*
cp -a ${hooksskeldir}/* ${svndir}/${repo}/hooks/
#--------
# Set the file permission on the new created repository.
find ${svndir}/${repo}/ -type d -exec chmod 2775 '{}' \;
find ${svndir}/${repo}/ -type f -exec chmod g+w '{}' \;
chmod 444 ${svndir}/${repo}/format
#--------
# Verify that the svnsync functions
svnsync sync --source-username ${syncuser} --source-password ${syncpass} file://${svndir}/${repo}

19 Sep 10 SVN + WebSVN(SSL) Installation in Debian Squeeze

These instructions show how to install the SVN system and the WebSVN via Apache SSL connection.
These instructions don’t explain much, I hope your are Linux/Apache savvy enough to understand them.

Install the needed Debian packages
apt-get install subversion libapache2-svn openssl ssl-cert
a2enmod ssl
a2enmod dav_svn

Everything in the dav_svn.conf configuration file is already disabled.
You can refer to it for more instructions on how to configure the module.

Create subversion repositories:
mkdir -p /var/svn
chown -R www-data:www-data /var/svn

All our subversion repositories should be located in /var/svn in order to be visible to Apache.
You can change /var/svn to any directory but you must configure WebSVN later accordingly.

Apache DAV_SVN and WebSVN Configuration
Lets move the default SSL configuration symlink out of the way
rm /etc/apache2/sites-enabled/default-ssl &>/dev/null

Create own SVN access configuration under an SSL VirtualHost as follows:
touch /etc/apache2/sites-available/ssl.conf
ln -s /etc/apache2/sites-available/ssl.conf /etc/apache2/sites-enabled/001-ssl.conf

Edit the file /etc/apache2/sites-available/ssl.conf and add this content.

<VirtualHost *:443>
     DocumentRoot /var/www
     # Authentication for all acesses here
     <Location />
          AuthType Basic
          AuthName "Subversion Repository"
          AuthUserFile /etc/apache2/dav_svn.passwd
          Require valid-user
     </Location>
     # ------------------ SVN ---------------------------------
     <Location /svn>
          DAV svn
          SVNParentPath /var/svn
          # this line must be added if you want SSL enabled
          SSLRequireSSL
     </Location>
     # ------------------WebSVN Client interface --------------
     <Directory /var/www/websvn>
          Options -Indexes +FollowSymlinks
          DirectoryIndex index.php
     </Directory>
     # ----------------- Some Extra SSL configuration needed ---------------
     <FilesMatch "\.(cgi|shtml|phtml|php)$">
          SSLOptions +StdEnvVars
     </FilesMatch>
     <Directory /usr/lib/cgi-bin>
          SSLOptions +StdEnvVars
     </Directory>
     # Solving the IE problems
     BrowserMatch ".*MSIE.*" \
          nokeepalive ssl-unclean-shutdown \
          downgrade-1.0 force-response-1.0
     SSLEngine on
     #Using Debian self-signed certificate
     SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
     SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key....
</VirtualHost>

Create authentication users
Create the authentication file(-c) and the first user (user1)
htpasswd -c /etc/apache2/dav_svn.passwd user1
Create the second user (user2)
htpasswd /etc/apache2/dav_svn.passwd user2

Restart Apache2
/etc/init.d/apache2 restart

Subversion Testing
svnadmin create /var/svn/test
chown -R www-data:www-data /var/svn/test
svn co https://new.site/svn/test

It should says “Checked out revision 0.”, otherwise try looking for the errors on the Internet.
You probably forgot some steps or I forgot to mention some details.

WebSVN client Installation


Get the package from the source in Internet
mkdir -p /var/www/
cd /var/www
wget http://websvn.tigris.org/files/documents/1380/49056/websvn-2.3.3.tar.gz
tar fvxz websvn-2.3.3.tar.gz
ln -s websvn-2.3.3 websvn
cp websvn/include/distconfig.php websvn/include/config.php

Edit /var/www/websvn/include/config.php.
Add the following line:
$config->parentPath('/var/svn');
You can set many other options but many of the default settings are enough for now.
Try webSVN interface:
https://server.name/websvn
After authenticating you should see the repository TEST (Top left of the browser)
This the TEST repository we created previously during the ‘svn testing’