Problem with my backup script FC4
Hello All..
Pretty sure this one is easy, but for whatever reason, it's always the easy problems that get me.
I have two drives on my Linux server (running Fedora core 4). HDA is my primary boot drive (40 Gb Seagate / ext3 Filesystem). HDB is my backup drive (120 Gb WD / FAT Filesystem). HDB is mounted automatically by FSTAB in read/write mode. Furthermore, several directories on this drive and on HDA are availabe over my Windows network via SAMBA. They are used for a variety of purposes (GHOST images, e-mail backup, etc..).
The one directory that is shared on HDA is /data/Common. On my XP machines, I changed the mapping of the "My Documents" folder to point to this directory. The idea was that everyone's "My Documents" folder was mapped to the same place. Believe it or not, this is working out very well. Problem is.. I don't trust Seagate. If this drive dies, I lose all my important documents in the /data/Common drive.
This would be very bad.
So, I would like to write a backup script that tar's up the contents of the /data/Common drive and moves that tarball onto the HDB drive. I have done this (rather, I found a backup script on the web). My script looks like:
#!/bin/sh
# full and incremental backup script
#Change the 5 variables below to fit your computer/backup
DIRNAME=Documents
COMPUTER=server # name of this computer
DIRECTORIES="/data/Common" # directories to backup
BACKUPDIR=/mnt/backup/Documents # where to store the backups
TIMEDIR=/mnt/backup/Documents/last-full # where to store time of full backup
TAR=/bin/tar # name and locaction of tar
#You should not have to change anything below here
PATH=/usr/local/bin:/usr/bin:/bin
DOW=`date +%a` # Day of the week e.g. Mon
DOM=`date +%d` # Date of the Month e.g. 27
DM=`date +%d%b` # Date and Month e.g. 27Sep
# On the 1st of the month a permanet full backup is made
# Every Sunday a full backup is made - overwriting last Sundays backup
# The rest of the time an incremental backup is made. Each incremental
# backup overwrites last weeks incremental backup of the same name.
#
# if NEWER = "", then tar backs up all files in the directories
# otherwise it backs up files newer than the NEWER date. NEWER
# gets it date from the file written every Sunday.
# Monthly full backup
if [ $DOM = "01" ]; then
NEWER=""
$TAR $NEWER -cvzf $BACKUPDIR/$DIRNAME-$DM.tar $DIRECTORIES
fi
# Weekly full backup
if [ $DOW = "Sun" ]; then
NEWER=""
NOW=`date +%d-%b`
# Update full backup date
echo $NOW > $TIMEDIR/$DIRNAME-full-date
$TAR $NEWER -cpfv $BACKUPDIR/$DIRNAME-$DOW.tar $DIRECTORIES
# Make incremental backup - overwrite last weeks
else
# Get date of last full backup
NEWER="--newer `cat $TIMEDIR/$DIRNAME-full-date`"
$TAR $NEWER -cvzf $BACKUPDIR/$DIRNAME-$DOW.tar $DIRECTORIES
fi
The /data/Common directory contains ~2Gb of data. When the script runs, it creates a file that is about 92Mb in size. Now, that can't be right. Apparently, the tarball contains only the folders in the /data/Common directory.. not the files in those directories. What's going on here?
I obviously need the script to copy the files, too..otherwise this is a wasted effort. What am I missing here is there some tar argument I need to use to force it to copy the files in the directories, too? Man page wasn't much help..
TIA for your wisdom
Regards
Anthony Krishock
|