what is wrong with my server 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's the error?
This looks like a script you got somewhere on the internet. I'm assuming you've edited this script to suite your environment? For example, you must fill in appropriate host names, directory names, etc. |
The below is the error message
"$HOST scp failed" "$HOST.$dat.tgz is no good" |
All times are GMT -5. The time now is 05:15 PM. |