วันศุกร์ที่ 30 พฤษภาคม พ.ศ. 2557

วันศุกร์ที่ 28 มีนาคม พ.ศ. 2557

วันจันทร์ที่ 3 มีนาคม พ.ศ. 2557

continuing svnsync from svn hotcopy

svnsync can be a time-consuming process if your revision is big. In this case, I will show how to continue the svnsync from hotcopy


1. Backup current by hotcopy
- svnadmin hotcopy /svn/repos/repos1/ /tmp/repos1

2. Copy data(/tmp/repos1) to new svn server directory /svn/repos/ (svn repository root) 

3. (optional) Upgrade SVN version property in case new SVN sever is  newer than old SVN server
- svnadmin upgrade

4. Initial SVN property for start svnysnc 
- svn propset --revprop -r0 svn:sync-last-merged-rev revno svn://hostname/reposname/
- svn propset --revprop -r0 svn:sync-from-uuid uuid svn://hostname/reposname/
- svn propset --revprop -r0 svn:sync-from-url svn://oldhost/reposname/ svn://hostname/reposname/

5. Sync data from old repos to new repos
- svnsync --non-interactive sync svn://hostname/reposname/

svnadmin dump, svnadmin load

svnadmin dump, svnadmin load
This sub-command can be use for back up and restore svn repository


Dump repository from SVN server
1. Dump SVN database from SVN server
- svnadmin dump /svn/repos/repos1/ | gzip -9 > /tmp/repos1.dump.gz

2. Copy file repos1.dump.gz for back up 

Restore from dumped repository
3. get svn server installed

4. Import SVN data from dump file with this command
- zcat repos1.dump.gz | svnadmin load /svn/repos/newrepos/

Mirroring svn


Mirror SVN server (and replace master server)

1. Install Mirror SVN server

2. Allow svnsync command permission 
- echo '#!/bin/sh' > /svn/repos/repos1/hooks/pre-revprop-change
- chmod +x /svn/repos/repos1/hooks/pre-revprop-change

3. Initial svnsync configure
- svnsync init svn://mirror/repos1/ svn://original/repos1/

 4. Start sync svn data
- svnsync --non-interactive sync svn://mirror

5. Setup schedule to resync svn
- crontab -e 
*/30 * * * * svnsync --non-interactive sync svn://mirror > /dev/null

- /etc/init.d/cron reload


In case you need mirror replace the master
- svnadmin setuuid /svn/repos/repos1/ uuid

replace   uuid from  /svn/repos/repos1/db/uuid 

svn/subversion server installation

Here are a short note for setting subversion server.

1. Install SVN server (subversion)
- apt-get install subversion

2. Create svnuser account
- useradd -m -s /bin/bash svnuser 

3. Create subversion working directory
- mkdir -p /svn/repos/
- chown svnuser.svnuser -R /svn/
- cd /svn/repos/

4. Change user access to svnuser
- su svnuser

5. Create svm repository
- svnadmin create repos1

6. Config repository password
- vi /svn/repos/repos1/conf/svnserve.conf

#####
anon-access = none
auth-access = write
password-db = passwd
#####

repository password file
- vi /svn/repos/repos1conf/passwd
#username and password example
user1 = pass1
- chmod 600 /home/ddsvn/wwwsvn/conf/passwd


7. Start SVN service
#login to svnuser account
- su svnuser
- svnserver -d -r /svn/repos/

8. Set svn start up on boot with user svnuser
- vi /etc/rc.local

#####
su svnuser -c "svnserve -d -r /svn/repos“
#####

APT cacher installation

Running several server with same distribution like ubuntu or debian. It is smart to have repository cache on your network. This can save your bandwidth and time.


Server side
1. Install apt-cacher mandatory package
$  apt-get install apt-cacher

2. Edit apt-cacher configuration
$  vi /etc/apt-cacher/apt-cacher.conf

#####
daemon_addr =
allowed_hosts = /
#####

3. Restart apt-cacher service
$  /etc/init.d/apt-cacher restart


Client side
1. Create proxy files for connect to apt-cacher
$  vi /etc/apt/apt.conf.d/01proxy

#####
Acquire::http::Proxy "http://:3142";
#####


How it work?
1. On client side try to use command apt-get update
2. On APT cacher server check logs file at /var/log/apt-cacher/access.log
to see client connection


Reference :
http://www.debuntu.org/how-to-set-up-a-repository-cache-with-apt-cacher/
https://help.ubuntu.com/community/Apt-Cacher-Server