full system backup script

Please help. I am new to linux. I wrote a script to run the backup on lunix machine but the job gave me an error. I am using Linux 2.6.14.3. Below is the sample of my script can anyone tell me where went wrong? Thanks in advance.

#!/bin/sh

dat=$(date +%d%b%y)
logdir="/usr/local/scripts/log/backup"
backuptarget="/*"
backupdir="/usr/hell/backups"

for HOST in devil1 devil2 devil3
do

ssh $HOST "tar -zcvpf $backupdir/$HOST.$dat.tgz $backuptarget --exclude "/usr/hell/DB" >> $backupdir/$HOST.backup.log.$dat "

ssh $HOST "cat $backupdir/$HOST.backup.log.$dat" >> $logdir/"$HOST.backup.log.$dat"
gzip $logdir/"$HOST.backup.log.$dat"

scp root@$HOST:$backupdir/$HOST.$dat.tgz $backupdir

# scp exits with 0 on success or >0 if an error occurred.

if [ $? -gt 0 ]; then
/var/netpage OPERATIONS -TSMS -G10.200.1.99 "$HOST scp failed"
fi

/bin/tar ztvf $backupdir/$HOST.$dat.tgz ||/var/netpage OPERATIONS -TSMS -G10.201.2.66 "$HOST.$dat.tgz is no good"

ssh $HOST "rm -f $backupdir/*"

done

/bin/tar -zcvpf $backupdir/devil1.$dat.tgz /* --exclude "/usr/hell/backups/" --exclude "/usr/hell/DB/" --exclude "/usr/dragon/.cache/*" >> $logdir/"devil1.backup.log.$dat"

gzip $logdir/"devil1.backup.log.$dat"

/bin/tar ztvf $backupdir/devil1.$dat.tgz ||/var/netpage OPERATIONS -TSMS -G10.200.1.99 "devil1.$dat.tgz is no good"

#zip up /usr/hell/backups directory as windows bkf file is big
gzip $backupdir/*

/bin/tar -rvpf /dev/st0 $backupdir/* /usr/hell/DB/200[4-6]*/* --exclude "*log*" >> $logdir/"tape.backup.log.$dat"
/bin/gzip $logdir/"tape.backup.log.$dat"
rm -f $backupdir/*

What is the error?

Thanks,

Joe

The below is the error message

"$HOST scp failed"
"$HOST.$dat.tgz is no good"

Your scp is failing here. Can you manually scp anything from root@devil1?

Try this (from the server where the script runs):

scp root@devil1:/etc/motd /tmp/motd.devil1

If this fails, you might need to look at the ssh configuration.

I also noticed that you are only running the scp as root. What user are the other ssh commands running as?

I only run as root.Will try the above.

I have try the above command and it work.

the error is "$HOST.$dat.tgz is no good" if run the backup script