Script to Backup SVN Repository

February 23, 2012 1 comment

This is a script to backup my svn repositories:

 

#!/bin/bash
# On this script I'm assuming that in the backup path 
# we only have .gz files so I use the same direcotry 
# as temp folder to dump the files there and gzip 
# them later


# Configuration
LOCKFILE=/var/lock/bkp_svn
#repository's names blank space separated
REPO_NAME_LIST="one two website source code"
REPO_PATH="/home/svn/repositories"
BKP_PATH="/backups/svn"
FLAG=0


# Check that there are no running backups
if [ -f $LOCKFILE ]; then
	echo "Instance already running"
	exit 1
fi

# Create the lock file to prevent multiple runs
touch $LOCKFILE

if [ ! -d ${REPO_PATH}/${REPO_NAME} ]; then
	echo "Repository Path: ${REPO_PATH} not found."
	exit 1
fi

# First lets create the dump files
for REPO_NAME in ${REPO_NAME_LIST}
do
	echo "Checking repository: ${REPO_NAME} ..."
	if [ -d ${REPO_PATH}/${REPO_NAME} ]; then
		svnadmin dump -q ${REPO_PATH}/${REPO_NAME} > ${BKP_PATH}/${REPO_NAME}.dump
		echo "${REPO_NAME} dumped."
		FLAG=1
	else
		echo "Repository ${REPO_NAME} not found."
	fi
done

#Now lets create the tar file
if [ ${FLAG} -eq 1 ]; then
	PREFIX_FILENAME=`date +"%y-%m-%d_%H%M"`
	cd ${BKP_PATH}
	tar -zcf ${PREFIX_FILENAME}.tar.gz *dump
	rm *dump
fi

echo "Script Finished"
rm ${LOCKFILE}
exit 0
Categories: backup, scripts, subversion

Upgrade to subversion 1.7.3

February 23, 2012 1 comment

Well, now that the version 1.7.3  of subversion was released let’s do a quick upgrade, I’m not going to paste here the steps to backup since they are already included here. Please always backup your stuff, it doesn’t take longer than the time you will have to spend if anything goes wrong and your info got corrupted or lost.

Now, lets download and prepare all we need.

wget http://apache.webxcreen.org/subversion/subversion-1.7.3.tar.gz
tar zxf subversion-1.7.3.tar.gz
cd subversion-1.7.3
wget http://apache.webxcreen.org//apr/apr-1.4.6.tar.gz
wget http://apache.webxcreen.org//apr/apr-util-1.4.1.tar.gz
tar zxf apr-util-1.4.1.tar.gz
tar zxf apr-1.4.6.tar.gz
mv apr-util-1.4.1 apr-util
mv apr-1.4.6 apr

Then since I’m using svnserve I have to kill the running version:

ps -fea | grep svnserve | grep -v grep | awk '{print $2}' | xargs kill -9

And Finally, lets compile and install.

./configure
make
make install
svn --version #You should see the 1.7.3 now
Categories: subversion

Prepare New Partition Linux

February 12, 2012 Leave a comment

I just got a new HD on my server so, I will use it to backup data, so lets get it ready:

First let’s check the status:

fdisk -l /dev/sdb

Disk /dev/sdb: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn't contain a valid partition table

Ok, I can see the disk so let’s create a primary partition of 144Gb (454656 Mb), I’m using this size because its the size of my current / partition and I might use this later on. So:

fdisk /dev/sdb
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-60801, default 1):<enter>
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-60801, default 60801): +454656M

Command (m for help): p

Disk /dev/sdb: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 1 55276 444004438+ 83 Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

Ok, the partition is ready to be formated:

mkfs.ext3 /dev/sdb1

Add the label: ‘/primarybackup’ to my just created partition and create the directory:

tune2fs -L/primarybackup /dev/sdb1

mkdir /primarybackup

Now add this line to /etc/fstab:

LABEL=/primarybackup    /primarybackup          ext3    defaults        0 0

Not lets mount it:

mount /primarybackup

Done, now you can write on /primarybackup

Categories: backup, filesystem Tags: , ,

Upgrade subversion to version 1.7 on CentOS

February 11, 2012 6 comments

Hi, this time I wanted to upgrade subversion on my CentOS box. So this is what I did:

First of all, take backup of your existing repositories (Assuming that I have a repository named: code and it is configured on svn under /home/svn/repositories/code):

svnadmin dump /home/svn/repositories/code > /backups/svn/code.dump

Now lets kill our running svn server:

ps -fea | grep svnserver
ps -fea | grep svnserve | grep -v grep | awk '{print $2}' | xargs kill -9

Now that I have my backups ready and the server is stopped I can go ahead and uninstall current svn version and then build from source and install the latest version, with these steps:

svn --version #Lets check which version we have now

yum remove subversion

cd /usr/local/src/

wget http://apache.tradebit.com/pub/subversion/subversion-1.7.2.tar.gz #got this from http://subversion.apache.org/download/ on the recomended download section

tar zxf subversion-1.7.2.tar.gz # Make sure you use the same filename from the previous step

cd subversion-1.7.2

wget http://rahulsoni.me/files/apr-util-1.3.12.tar.gz

wget http://rahulsoni.me/files/apr-1.4.5.tar.gz

tar zxf apr-util-1.3.12.tar.gz

mv apr-util-1.3.12 apr-util # When using ./configure it will look for these files by default on a folder without version number

tar zxf apr-1.4.5.tar.gz

mv apr-1.4.5 apr # When using ./configure it will look for these files by default on a folder without version number

./configure

Now after my first try to get this working, it failed because of the sqlite version, so if you get this message after trying ./configure :

checking sqlite library version (via header)... unsupported SQLite version
checking sqlite library version (via pkg-config)... none or unsupported 3.3
no

An appropriate version of sqlite could not be found. We recommmend
3.7.6.3, but require at least 3.6.18.

Then you would need to install sqlite 3.7.X you can do it by installing atomic repository and updating using yum:

sqlite3 -version #check current version

wget -q -O - http://www.atomicorp.com/installers/atomic | sh # To install Atomic repository

yum --enablerepo=atomic upgrade sqlite

sqlite3 -version #you should get the 3.7 version listed now

Now that we have the updated sqlite, lets continue with the subversion install:

./configure

make

make install

svn --version # Now you should see the latest version

Now, go to all of your local working directories and do a svn upgrade:

cd /application/code

svn upgrade

And Thats it!! You now have the 1.7 svn working version.

Categories: subversion Tags: , ,