I wrote a shell script that does this same thing, minus the info from the PID, but that is an interesting idea
Instead of cutting and pasting the whole thing here, I could give you a few ideas, and if that doesn't do the trick I'll stick the whole file up for download.
This one works with the .bz2 compression, which I found to be much more compressed (although more time consuming). you can do it in any compression you like of course.
#*******************************
#!/bin/bash
#*******************************
#
#day of month cannot have the padded ( 1) format
#it must be (01) format therefore the %m
#You can read about the options for "date" in the man pages
#and customize it for your app
#
#now call date variables for file naming
#******************************
cyear=`date +'%y'`
fyear=`date +'%Y'`
wday=`date +'%a'`
cdate=`date +'%d'`
month=`date +'%m'`
company=dba
sco=dba
dirpath=/mnt/nt/autobackup
backuppath=/mnt/central/Default
logpath=/var/log/hh
file=$company-$wday-$month-$cdate-$fyear.tar.bz2
#variables all set...now back up
#
echo Creating date file...
#this begins the log file building
#
cd $logpath/$sco
echo $backuppath/$company > datefile
echo This File created by automated Linux backup program running in cron >> datefile
echo -n "Time started: " >> datefile
date >> datefile
date
#
echo " *********Starting $sco Backup now*********** "
#
echo changing directories
cd $dirpath/$sco
echo Starting backup attempt on $backuppath/$company
tar -Icf $company-$wday-$month-$cdate-$fyear.tar.bz2 $backuppath/* |sleep 5
#
# Finish building the time stamp in the log file
echo -n "Time finished: " >> $logpath/$sco/datefile
date >> $logpath/$sco/datefile
# this ends log file building
# log files are overwritten every time it runs
# This last check goes to see if the file/folder we
# "think" we backed up is actually there
test -e $dirpath/$sco/$file
# I forget why this works...but it does!
new=$?
if [ "$new" = "0" ]
then
cat $logpath/$sco/datefile | /bin/mail -s "$sco backed up" you@your.com
echo Hooray $dirpath/$sco/$file Successfully Created!
else
echo Backup NOT completed: Go Fix it!
/bin/mail -s "Something is wrong with $sco" you@your.com
echo Exiting backup prgram for $sco
exit
fi
echo Exiting backup program for $sco.....
#####################
This will give you dated .tar.bz2 files in a directory.
Looks like:
dba-Fri-08-08-2003.tar.bz2
Hope this helps!