Tuesday 30 July 2013

svn migration

Installing the svn at the new server

  1. login to the new jira/svn server.
  2. I have already created an account "svn", so login to the svn user.
  3. Keeping the similar directory structure so keeping creating a dir as repos under /home/svn dir.
  4. sudo su - svn
  5. mkdir repos
  6. Copy the old repo backup.
  7. sudo apt-get install subversion
  8. svnadmin create /home/svn/repos/repos_name [ This will create a repository ]
  9. svnadmin load /home/svn/repos/repos_name < /from/the/backup/repo.file   [ This will load the svn backup ]
  10. Start the svn server [ svnserve -d -r /home/svn/repos ] -> [ Here you have to provide the repo directory ]
  11. By default svn run at port: 3690

How to kill or stop svn server

  1. You need to kill the svn server.
  2. grep for the svnserve and then kill that pid.

How you will do a basic test

  1. check for the svnserve service is running or not.
  2. log in to any of your client server. [ I am using a ubuntu client ]
  3. on the client [ svn client ]
  4. svn checkout svn://<ip_of_svn_server>/repo/path

Big question

  1. its not asking for the username and password?
Got it:

You need to have the following file updated [ /home/svn/repos/repos_name/conf ]

cat svnserve.conf
### This file controls the configuration of the svnserve daemon, if you
### use it to allow access to this repository.  (If you only allow
### access through http: and/or file: URLs, then this file is
### irrelevant.)

### Visit http://subversion.tigris.org/ for more information.

[general]
### These options control access to the repository for unauthenticated
### and authenticated users.  Valid values are "write", "read",
### and "none".  The sample settings below are the defaults.
anon-access = none
auth-access = write
### The password-db option controls the location of the password
### database file.  Unless you specify a path starting with a /,
### the file's location is relative to the directory containing
### this configuration file.
### If SASL is enabled (see below), this file will NOT be used.
### Uncomment the line below to use the default password file.
password-db = passwd
### The authz-db option controls the location of the authorization
### rules for path-based access control.  Unless you specify a path
### starting with a /, the file's location is relative to the the
### directory containing this file.  If you don't specify an
### authz-db, no path-based access control is done.
### Uncomment the line below to use the default authorization file.
# authz-db = authz
### This option specifies the authentication realm of the repository.
### If two repositories have the same authentication realm, they should
### have the same password database, and vice versa.  The default realm
### is repository's uuid.
realm = Your company Name.

Then comment update the following at file "authz"
~/repos/repos_name/conf$ cat authz 
### This file is an example authorization file for svnserve.
### Its format is identical to that of mod_authz_svn authorization
### files.
### As shown below each section defines authorizations for the path and
### (optional) repository specified by the section name.
### The authorizations follow. An authorization line can refer to:
###  - a single user,
###  - a group of users defined in a special [groups] section,
###  - an alias defined in a special [aliases] section,
###  - all authenticated users, using the '$authenticated' token,
###  - only anonymous users, using the '$anonymous' token,
###  - anyone, using the '*' wildcard.
###
### A match can be inverted by prefixing the rule with '~'. Rules can
### grant read ('r') access, read-write ('rw') access, or no access
### ('').

#[aliases]
# joe = /C=XZ/ST=Dessert/L=Snake City/O=Snake Oil, Ltd./OU=Research Institute/CN=Joe Average

[groups]
# harry_and_sally = harry,sally
# harry_sally_and_joe = harry,sally,&joe

# [/foo/bar]
# harry = rw
# &joe = r
# * =

# [repository:/baz/fuz]
# @harry_and_sally = rw
# * = r

ReadOnlyUserName=r

Then update the "passwd" file with user's auths.
example:

~/repos/repos_name/conf$ cat passwd 
### This file is an example password file for svnserve.
### Its format is similar to that of svnserve.conf. As shown in the
### example below it contains one section labelled [users].
### The name and password for each user follow, one account per line.

[users]
# harry = harryssecret
# sally = sallyssecret


After this kill all the svn service and start it again.

sudo killall svnserve 
svnserve -d -r /home/svn/repos




######## SVN Hooks #########

http://svnbook.red-bean.com/nightly/en/svn.reposadmin.create.html
http://svnbook.red-bean.com/nightly/en/svn.ref.reposhooks.html

The hooks subdirectory is, by default, filled with templates for various repository hooks:

$ ls repos/hooks/
post-commit.tmpl          post-unlock.tmpl  pre-revprop-change.tmpl
post-lock.tmpl            pre-commit.tmpl   pre-unlock.tmpl
post-revprop-change.tmpl  pre-lock.tmpl     start-commit.tmpl
$
 
NOTE: The hooks files should be own by svn server's process owner and need to have executable permission.
NOTE: If its not having executable permission it will not work.
NOTE: If its not owned by proper user, it will not work.
 
-rwx-wx--x 1 svn svn  2764 2014-03-04 03:53 pre-revprop-change  
-rwx-wx--x 1 svn svn  7208 2014-03-04 03:53 pre-commit
-rwx-wx--x 1 svn svn 45233 2014-03-04 03:53 post-commit.1
 
DO a must test of: eol-style, by adding a new file...
 


 To actually install a working hook, you need only place some executable program or script into the repos/hooks directory, 
which can be executed as the name (suchas start-commit or post-commit) of the hook.
 

Subversion executes hooks as the same user who owns the process that is accessing the Subversion repository. In most cases, the repository is being accessed via a Subversion server, so this user is the same user as whom the server runs on the system. The hooks themselves will need to be configured with OS-level permissions that allow that user to execute them. Also, this means that any programs or files (including the Subversion repository) accessed directly or indirectly by the hook will be accessed as the same user. In other words, be alert to potential permission-related problems that could prevent the hook from performing the tasks it is designed to perform.

Example 5.1. hooks-env (custom hook script environment configuration)

# All scripts should use a UTF-8 locale and have our hook script
# utilities directory on the search path.

[default]
LANG = en_US.UTF-8
PATH = /usr/local/svn/tools:/usr/bin


# The post-commit and post-revprop-change scripts want to run
# programs from our custom synctools replication software suite, too.

[post-commit]
PATH = /usr/local/synctools-1.1/bin:%(PATH)s

[post-revprop-change]
PATH = /usr/local/synctools-1.1/bin:%(PATH)s



Common uses for hook scripts

Repository hook scripts can offer a wide range of utility, but most tend to fall into a few basic categories: notification, validation, and replication.

Notification scripts are those which tell someone that something happened. The most common of these found in a Subversion service offering involve programs which send commit and revision property change notification emails to project members, driven by the post-commit and post-revprop-change hooks, respectively. There are numerous other notification approaches, from issue tracker integration scripts to scripts which operate as IRC bots to announce that something's changed in the repository.






## How to see the tree structure.

This shows the tree output for revision 13 in our sample repository:
 
$ svnlook tree -r 13 /var/svn/repos
/
 trunk/
  button.c
  Makefile
  integer.c
 branches/
  bookstore/
   button.c
   Makefile
   integer.c


http://svnbook.red-bean.com/en/1.7/svn.ref.svnlook.html#svn.ref.svnlook.sw.full_paths

# About svn property:

To set the property: [ NOTE You most configure your svn server not to commit any file, if atleast "svn:eol-style " is not set.
 
svn propset svn:eol-style native path/of/file
svn propset svn:mime-type application/octet-stream path/of/file

To list the property:
svn proplist -v path/of/file

To delete the property:
svn propdel <your_property> path/to/file

# To Restart:

pkill svn; ps aux | grep -i svnserve | grep -v grep ; svnserve -d -r /home/svn/repos; ps aux | grep -i svnserve | grep -v grep


# SVN Error:
svn: E165001: Commit blocked by pre-commit hook (exit code 255) with no output.
http://stackoverflow.com/questions/11016458/commit-blocked-by-pre-commit-hook-svn


There are two different types of pre-commit hooks:
  • Server side: This is the standard Unix pre-commit hook. The hook itself lives inside the repository hooks directory. If the hook is not executable, or there is no hook script called pre-commit the hook does not run.
  • TortoiseSVN Client Side Hooks: The hook is on the client and is specific to TortoiseSVN.




http://stackoverflow.com/questions/tagged/svn

-Amit Kumar Mund

No comments:

Post a Comment