Archive

Archive for the ‘backup’ Category

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
Advertisements
Categories: backup, scripts, 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: , ,