Monday, August 26, 2013

SVN svnsync recreate

If you have some specific problem with a known good svn mirror, i.e. you can no longer checkout files from this mirror due to errors like url was changed, uuid not matched, etc. run svnsync switch:

svn propset --revprop -r 0 svn:sync-from-url http://my.new/url url://to.my.repo
for example, provided the mirror is local:
svn propset --revprop --username  myname -r 0 svn:sync-from-url svn://xx.xx.xxx.xx:9999  file:///var/www/svn/svn_mirror

Now you can run svnsync to sync from the new URL
svnsync –non-interactive sync --username=<name> url://to.my.repo
for example:
/usr/bin/svnsync sync --non-interactive --username myname  file:///var/www/svn/svn_mirror


And for whatever reason, worst case scenario is if you have to recreate the mirror:
1. move current mirror
    mv  /var/www/svn/<repo1>   /var/www/svn/<repo1>.OLD
2. create new repo with same name
    svnadmin create /var/www/svn/<repo1>
    chown -R apache  /var/www/svn/<repo1>
    chgrp  -R labtools  /var/www/svn/<repo1>
3. copy pre-revprop-change to preserve the auth.
    cp /var/www/svn/<repo1>.OLD/hooks/pre-revprop-change  /var/www/svn/<repo1>/hooks/
4. init the mirror
    svnsync init --username <user>   file:///var/www/svn/<repo1>  svn://<svn repository>
5. sync the mirror
    svnsync sync --username <user>   file:///var/www/svn/<repo1>
6. delete old mirror
    rm  -rf  /var/www/svn/<repo1>.OLD



--------------------------------
FYI: subversion server setup RHEL and centOS:

install apache server and php:
yum --enablerepo=remi install httpd php php-common

install dependencies:
yum install php-pecl-apc php-cli php-pear php-pdo php-mysql php-pgsql php-pecl-mongo php-sqlite php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml

start apache:
/etc/init.d/httpd start ## use restart after update
## OR ##
service httpd start ## use restart after update

chkconfig --levels 235 httpd on

add this /var/www/html/test.php file
<?php
    phpinfo();
?>

install subversion:
yum install mod_dav_svn subversion

create svn directory:
mkdir /var/www/svn
cd /var/www/svn

svnadmin create repos1
chown -R apache.apache repo1

chcon -R -t httpd_sys_content_t /var/www/svn/repo1

## Following enables commits over http ##
chcon -R -t httpd_sys_rw_content_t /var/www/svn/repo1


modify Subversion config file /etc/httpd/conf.d/subversion.conf

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>

## Create testuser ##
htpasswd -cm /etc/svn-auth-users testuser
New password:
Re-type new password:
Adding password for user testuser

## Create testuser2 ##
htpasswd -m /etc/svn-auth-users testuser2
New password:
Re-type new password:
Adding password for user testuser2

always restart httpd when made change to config file
/etc/init.d/httpd restart

No comments:

Post a Comment