Backups
OK, we’ll get back to the It’s Dead Jim serious later where I will eulogize my dead hard drive, but for now I thought I’d discuss what I’ve been working on off and on over the past few weeks.
A few years ago, we had a Novell 4.x server and a 12GB tape backup. We upgraded to a SuSE Linux Enterprise Server(SLES) and continued to use the tape backup. The problem was we had around 40GB of data. That meant a full backup used 4 tapes. This was annoying, having to change tapes and all, so I decided to try something different. So now we have 2 250GB NAS drives. That was all fine and well, but I’ve been trying to find the right software to do all I want. I used some open source stuff but I didn’t like the way it worked, I used WindowsXP’s built-in backup software for some time, but it was finicky. So I finally decided just to use tar and gzip. Then I decided I should probably encrypt my data, so I’m using openssl as well. So what I’ve been working on is perfecting a backup script scheduled in cron to do my regular backups. I have 2 drives so I can carry one offsite. So I’ve setup my schedule for full backups and differential backups in such a way that if I lost one drive and the server I’d still be able to recover data from the remaining drive and have all the data up-to-date within 1 weeks time.
So here’s the schedule at the moment:
Monday Full backup to drive1
Tuesday Diff backup to drive 2
Wednesday Diff backup to drive 1
Thursday Full backup to drive 2
Friday Diff backup to drive 1
At the moment I have a script for each day of the week that tars all the files I want to backup, then on the diff backups I gzip them, it takes too long for the full backups since we have 110GB to backup, then I use openssl to encrypt all the files with des3. The NAS drives have to be mounted using smbfs so there is a 2GB file size limit, so the script has to allow for that as well. Here’s a sample of my monday night backups:
#!/bin/bash
# Create backups of /etc, /home, /usr/local, and…
PATH=/bin:/usr/bin
DIRS=’/etc /srv /root /usr/local /var/lib /home’
echo “Mounting backup drive MISSIONS-PICS” | logger -t mon:backup
mount -t smbfs -o username=,password= //Missions-Pics/NetHDD /mnt/Pics | logger -t mon:backup
echo “Backup drive Missions-Pics Mounted” | logger -t mon:backup
echo “Removing Previous Backup files from MISSIONS-PICS” | logger -t mon:backup
rm -R /mnt/Pics/monday.* | logger -t mon:backup
echo “Previous Backup Files Removed” | logger -t mon:backup
echo “Setting date for Incremental backup” | logger -t mon:backup
date > /root/last
echo “Stopping exchange4linux” | logger -t mon:backup
/usr/sbin/exchange4linux-all-ctl stop | logger -t mon:backup
echo “System backup of ” $DIRS | logger -t mon:backup
for (( i = 0 ; i <= 100 ; i++ ))
do
backup=$backup–file=/mnt/Pics/monday.$i.tar’ ‘
done
tar cvR –tape-length=2000000 $backup $DIRS | logger -t mon:backup
sleep 2
echo “Starting Exchange4linux” | logger -t mon:backup
/usr/sbin/exchange4linux-all-ctl start | logger -t mon:backup
echo “Encrypting backup of ” $DIRS | logger -t mon:backup
for (( i = 0 ; i <= 100 ; i++ ))
do
openssl des3 -e -salt -pass file:/root/pass -in /mnt/Pics/monday.$i.tar -out /mnt/Pics/monday.$i.tar.des3 | logger -t mon:backup
rm /mnt/Pics/monday.$i.tar | logger -t mon:backup
sleep 2
done
echo “System backups complete, status: $?” | logger -t mon:backup
echo “Umounting Backup Drive CHCCBACKUP” | logger -t mon:backup
umount /mnt/Pics | logger -t mon:backup
echo “Backup Drive CHCCBACKUP successfully umounted” | logger -t mon:backup
echo “Please remove backup Drive” | logger -t mon:backup
Still needs alot of tweaking, but it works for now.
What? Xanga’s not good enough for you? It’s not like you’ve used all of its resource, and I don’t think you’re planning on getting TOSsed…