이런저런 연유로 SVN Server에 직접 접근은 불가능하고 mount를 이용해 file로 접근 가능한 방법을 찾아야만 하는 상황이 생겼다.

그래서 사용하게 된 방법이 SVN mirroring.

미러링에도 여러가지 방법이 있으나 그 중에서 svnsync를 사용하기로 했고 아래처럼 해서 성공.

원격에 있는 SVN 저장소를 $REPO라고 가정하고

로컬에 미러링할 경로를 $MIRROR라고 하자.

1. 우선 빈 저장소를 하나 생성한다.

svnadmin create $MIRROR

2. 오류없이 생성되었다면 $MIRROR/hooks 경로에 pre-revprop-change 라는 파일을 하나 생성한다.

hook에 가보면 임시 파일도 있으니 이용해도 되고 exit 0; 으로 종료되는 파일을 생성해줘도 된다.

pre-revprop-change 라는 파일은 revision 정보가 바뀔 때 실행되는 파일로 보이는데 svnsync 자체를 제한한다거나 하는 용도로 이용 가능.

예를 들어 아래와 같은 내용을 추가해두면 svnsync를 userA 이외에는 사용 못하게 할 수 있다.

(userA가 아닌 경우 실행시 메세지를 출력하고 1을 리턴하면서 실패로 종료됨)

#!/bin/sh
USER=”$3″
if [ "$USER" = "userA" ]; then exit 0; fi
echo “Only the userA user can change revprops” >&2
exit 1

3. 그 이후에 실행 권한을 부여한다.

chmod +x $MIRROR/hooks/pre-revprop-change

4. 그 다음은 svnsync 초기화 작업. (원격 SVN 저장소와의 초기화)

svnsync init –username userA file://$MIRROR $REPO

5. 마지막으로 동기화하라고 아래처럼 명령을 내리면 원격 저장소에 있는 내용과 동기화를 하게 된다.

svnsync sync file://$MIRROR

문제 중 하나는 sync 명령을 내릴 때만 동기화를 하지 자동으로 동기화를 진행하지는 않는다는건데

post-commit을 이용해 commit 발생시 동기화를 시키도록 스크립트를 만들던지 크론탭 등의 스케줄러를 이용하는 방법을 이용해야 할 것으로 보임.

 

출처 : http://blurblah.net/

'Dev > SVN' 카테고리의 다른 글

using svnsync  (0) 2013.01.02
SVN *.a library 추가 방법  (0) 2011.12.07

Garrett helped write svnsync as part of Subversion 1.4, but I wasn’t able to find any documentation for it, other than passing –help.

svnsync is a one way replication system for Subversion. It allows you to create a read-only replica of a repository over any RA layer (including http, https, svn, svn+ssh).

First, lets setup the initial sync. We have two repositories, I will skip the details of svnadmin create. For the remote access to the replica repository, I used svnserve, and I added a user with full write access. The destination repository should be completely empty before starting.

So, to make this easier, I am going to put the repository URIs into enviroment variables:

$ export FROMREPO=svn://svn.example.com/
$ export TOREPO=svn://dest.example.com/

Because the svnsync is allowed to rewrite anything on the TOREPO, we need to make sure the commit hooks are configured to allow our ‘svnsync’ user to do anything it wants.

On the server hosting TOREPO, I ran this:

$ echo "#!/bin/sh" > hooks/pre-revprop-change
$ chmod 755 hooks/pre-revprop-change

Now we are ready to setup the sync:

$ svnsync init ${TOREPO} ${FROMREPO}

This will prompt you for the username, password, and also sets several revision properties on the $TOREPO, for revision zero. It doesn’t actually copy any of the data yet. To list the properties that it created, run:

$ svn proplist --revprop -r 0 ${TOREPO}

  svn:sync-from-uuid
  svn:sync-last-merged-rev
  svn:date
  svn:sync-from-url

$ svn propget svn:sync-from-url --revprop -r 0 ${TOREPO}

  svn://svn.example.com/

So all the knowledge about what we are syncing from is stored at the destination repository. No state about this sync is stored in the source repository.

We are now ready to begin copying data:

$ svnsync --non-interactive sync ${TOREPO}

And if everything is setup correctly, you will start replicating data.

Except, I suck. And the first thing I did was hit control+c. I figured this is a cool replication system, so I just ran the sync command from above again, and got this:

$ svnsync --non-interactive sync ${TOREPO}

Failed to get lock on destination repos, currently held by 'svn.example.com:0e4e0d98-631d-0410-9a00-9320a90920b3'
Failed to get lock on destination repos, currently held by 'svn.example.com:0e4e0d98-631d-0410-9a00-9320a90920b3'
Failed to get lock on destination repos, currently held by 'svn.example.com:0e4e0d98-631d-0410-9a00-9320a90920b3'
Failed to get lock on destination repos, currently held by 'svn.example.com:0e4e0d98-631d-0410-9a00-9320a90920b3'
Failed to get lock on destination repos, currently held by 'svn.example.com:0e4e0d98-631d-0410-9a00-9320a90920b3'
Failed to get lock on destination repos, currently held by 'svn.example.com:0e4e0d98-631d-0410-9a00-9320a90920b3'
Failed to get lock on destination repos, currently held by 'svn.example.com:0e4e0d98-631d-0410-9a00-9320a90920b3'
Failed to get lock on destination repos, currently held by 'svn.example.com:0e4e0d98-631d-0410-9a00-9320a90920b3'
Failed to get lock on destination repos, currently held by 'svn.example.com:0e4e0d98-631d-0410-9a00-9320a90920b3'
Failed to get lock on destination repos, currently held by 'svn.example.com:0e4e0d98-631d-0410-9a00-9320a90920b3'
svnsync: Couldn't get lock on destination repos after 10 attempts

Oh snap. I guess its not so easy to restart after an aborted sync.

I started debugging, and found that svnsync kept its lock state in a special property in revision zero again.

So, To fix this, we can safely just delete this lock:

$ svn propdelete svn:sync-lock --revprop -r 0  ${TOREPO}

Now running sync again works! Hurrah!

After the sync finishes, we will want to keep the replica up to date.

I personally set a ‘live’ sync, but it is also possible to use a crontab or other scheduling method to invoke sync whenever you want.

To setup a live sync, on the FROMREPO server, I appended this to my hooks/post-commit file:

svnsync --non-interactive sync svn://dest.example.com/ &

You will want to make sure that the user-running subversion (and the hook script) has a cached copy of the authentication info for the destination repository.

Unfortunately, the post-commit hook won’t catch everything, so we also need to added this to the post-revprop-change hook:

svnsync --non-interactive copy-revprops  svn://dest.example.com/ ${REV} &

This will help propagate things like editing svn:log messages.

And there you go, thats the path I took to mirror one of my repositories onto another machine.

 

출처 : http://journal.paul.querna.org/articles/2006/09/14/using-svnsync/

'Dev > SVN' 카테고리의 다른 글

svnsync 명령을 이용해 SVN mirroring 하기  (0) 2013.01.02
SVN *.a library 추가 방법  (0) 2011.12.07
확장자가 "a"인 라이브러리 파일이

SVN에 커밋하거나 임포트할 때 적용이 안된다.

해결을 하기 위하여 터미널에서 아래의 명령어를 활용하면 된다.

 

global-ignores = *.o *.lo *.la *.al .libs *.so *.so.[0-9]* *.a *.pyc *.pyo

 

svn add "file" --no-ignore

 

svn status --no-ignore


svn add "library.a" --no-ignore
사용 방법은 아래 링크를 활용하세요
출처 : http://blog.naver.com/rich_happy/30124595833

'Dev > SVN' 카테고리의 다른 글

svnsync 명령을 이용해 SVN mirroring 하기  (0) 2013.01.02
using svnsync  (0) 2013.01.02

+ Recent posts