rulururu

post Automated Incremental Backups With rsync

April 28th, 2007

Filed under: Linux, Operating Systems — Brenton Alker @ 15:28

When I installed my software RAID array, I was a little unsure of stability, mainly because I’ve never configured RAID before, not because the software is unstable. So as a precaution, I decided to create a backup scheme (which I should have had anyway).

Using some tools found on almost every Linux system, "rsync" and "cp", I wrote a script, to create incremental backups of my /home directory.

My code looks like this:

/usr/local/sbin/backup.sh

#!/bin/sh
SRC_DIR=/home
BACKUP_DIR=/backup
BACKUPS=14
# Delete the oldest backup
if [ -d ${BACKUP_DIR}${SRC_DIR}.${BACKUPS} ]
then
rm -rf ${BACKUP_DIR}${SRC_DIR}.${BACKUPS}
fi
SRC=0
for i in `seq ${BACKUPS} -1 2`
do
let SRC=$i-1
if [ -d ${BACKUP_DIR}${SRC_DIR}.${SRC} ]
then
mv ${BACKUP_DIR}${SRC_DIR}.${SRC} ${BACKUP_DIR}${SRC_DIR}.${i}
fi
done
if [ -d ${BACKUP_DIR}${SRC_DIR}.0 ]
then
cp -al ${BACKUP_DIR}${SRC_DIR}.0 ${BACKUP_DIR}${SRC_DIR}.1
fi
rsync -a –update –delete ${SRC_DIR}/ ${BACKUP_DIR}${SRC_DIR}.0
touch ${BACKUP_DIR}${SRC_DIR}.0

It incrementally backs up the entire /home directory to /backup, by placing it in my crontab:

@daily /usr/local/sbin/backup.sh

I can, without intervention, maintain 2 weeks worth of backups.

Since this is basically a single user system, and the backups are only meant to protect against my stupidity, I haven’t gone to the trouble of making the backups read-only. But this would certainly be an improvement to the system. A couple of solutions are discussed in the article that my script is based on. Mine only backs up to a different directory (which is mounted on a different drive), not to a separate system/location (although, this is a good idea if possible).

As a side note, I haven’t had any trouble with the RAID, but backups are still reassuring.

post Configuring Software RAID With mdadm

April 23rd, 2007

Filed under: Debian, Linux, Operating Systems — Brenton Alker @ 15:14

Along with the old server machines I collected from the office (that this server is currently running on) came a plethora of hard disks of varying sized. I decided to put a couple of them to use in a RAID array to protect my important (not really) data.
The motherboard in my (much newer) desktop machine comes equipped with a RAID compatible disk controller, that I have never made use of. Unfortunately, the machine I have constructed as my server does not.

Never fear, software raid to the rescue. While I was (and still am) led to believe that software RAID is considerably slower than its hardware equivalent, my current array performs comparably, even slightly better (at least for reads), than the individual disks. So it is definitely a viable solution.

So I now have a simple 2 disk mirrored array, and in it’s creation dispelled a few more of my own misconceptions.

RAID array can be configured using partitions on an already partitioned drive (probably even using the 2 partitions on the same disk, but I didn’t try as it sort of defeats the purpose).

Using mdadm, a newer much friendlier (than the older raidtools) solution to software RAID on linux, to set up a software RAID is actually a fairly simple task.

As I was creating an new array from blank disks, the majority of the configuration is one command:

mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2 /dev/hdb1 /dev/hdc1

Where /dev/md0 is the new software raid device and /dev/hdb1 and /dev/hdc1 are the 2 partitions that are to be used to create the array. If there is already data that needs to be preservered the "Create Degraded array, Add new disk" approach (described in much more detail in an article on SourceForge).

and then

mdadm --examine --scan >> /dev/mdadm/mdadm.conf

to save the configuration (it works without the configuration file, it just makes life a little easier)

I am yet to set up monitoring, but according to Linux dev center that is fairly simple too.

The configuration of a RAID array was much simpler and less interesting than I anticipated, but I suppose that’s a good thing for the server administration world in general.

post Debian Etch Install

April 19th, 2007

Filed under: Debian, Linux, Operating Systems — Brenton Alker @ 22:05

As I mentioned previously, I just replaced my server. The side-effect of this is that I need to perform a fresh install of all the software (unless I just move the drives of course, but I still want to use the old server).

I’ve decided to stay with Debian as my server distribution as I haven’t had any major issues with it and it is easy to administer, as well as being the parent distribution of my desktop OS, Ubuntu… makes it easier for my little brain to keep track of.

For the last few Debian installations I’ve done I’ve used to greater or lesser extents an really well written article that offers a step-by-step guide to the installation of an "almost ISP ready server". While it is written for Debian 3.1 (Sarge) I have used it to install Deiban 4 (Etch) on a number of occasions.

The majority of the process is the same, with the exception of a few packages that I prefer newer versions of; such as Apache 2, PHP 5 and MySQL 5. Facilitating the need to alter a few of the "cut-and-paste" instructions. The guide can be followed beginning to end, or just follow the sections detailing the services you are after.

Note: I’ve since discovered that the author (Falko Timme) has also written an article for details the installation of Etch, so maybe I’ll use that next time. Unless I decide to install Lenny by then.

ruldrurd
Powered by WordPress, Web Design by Laurentiu Piron
Entries (RSS) and Comments (RSS)