Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

output from backup script 2

Status
Not open for further replies.

sirrom

Technical User
Jul 11, 2001
80
GB
This a follow on from a previous problem.
(Thanks for the help kencunnigham)

I want to capture the output below to my $LOGFILE

bash# ./sys
backup: The date of this level 0 backup is Wed 27 Feb 11:07:06 2002.
backup: The date of the last level 0 backup is the epoch.
backup: Backing up /dev/rjnllv (/jnl) to /dev/rmt0.
backup: 0511-251 The file system is still mounted; data may not be consistent.
Use the umount command to unmount the filesystem; then do the backup.
backup: Mapping regular files. This is Pass 1.
backup: Mapping directories. This is Pass 2.
backup: There are an estimated 21426 1k blocks.
backup: Backing up directories. This is Pass 3.
backup: Backing up regular files. This is Pass 4.
backup: There are 21610 1k blocks on 1 volumes.
backup: There is a level 0 backup on Wed 27 Feb 11:07:06 2002.
backup: The tape is rewinding.
backup: The backup is complete.


However all I get is:

Now starting the backup /jnl Wed 27 Feb 11:07:06 2002
Now starting the backup /var Wed 27 Feb 11:07:56 2002
Backup Completed onWed 27 Feb 11:08:23 2002

the command I use is:

# Do the backup
for x in /jnl /var

do
echo "Now starting the backup $x `date`" >> $BACKUPLOG
backup -0 -u -f /dev/rmt0 $x
if [ $? -ne 0 ]; then
echo "backup aborted at `date`" >> $BACKUPLOG
exit 1
fi

I have tried using a -v flag but it does not like being used with -0 -u flags.
 
Need to do the following,but must be in ksh (not in c or tcsh !):

# Do the backup
for x in /jnl /var

do
echo "Now starting the backup $x `date`" >> $BACKUPLOG
backup -0 -u -f /dev/rmt0 $x 2>&1 >> $BACKUPLOG
if [ $? -ne 0 ]; then
echo "backup aborted at `date`" >> $BACKUPLOG
exit 1
fi
"Long live king Moshiach !"
 
sirrom, you probably need:

backup -0 -u -f /dev/rmt0 $x >> $BACKUPLOG

Give it a go and good luck!
 
Unfortunately in order to have everything in the log - both standard errors and standard output - he needs to use "2>&1" syntax,as I have stated. "Long live king Moshiach !"
 
Very true. Strangely enough I just came back here to say the very same thing! Cheers.
 
I have added the 2>&1 but it still does not give me the standard output. Only:
Now starting the backup /jnl Wed 27 Feb 14:33:29 2002
Now starting the backup /var Wed 27 Feb 14:34:19 2002
Backup Completed on Wed 27 Feb 14:34:46 2002
Is this an AIX anomaly ?

Here's the script in full.
Thanks for the help.

#!/usr/bin/ksh

BACKUPLOG=/mydir/dumplog.`/bin/date +%d-%m-%Y`.$$

# Rewind the tape
mt -f /dev/rmt0 rewind

# Do the backup
for x in /jnl /var

do
echo "Now starting the backup $x `date`" >> $BACKUPLOG
backup -0 -u -f /dev/rmt0 $x 2>&1 >> $BACKUPLOG
if [ $? -ne 0 ]; then
echo "backup aborted at `date`" >> $BACKUPLOG
exit 1
fi
done
# End Message
echo 'Backup Completed on' `date` >> $BACKUPLOG
# Rewind & give me the tape !
#mt -f /dev/rmt0 rewoff # un-hash this later
 
Try:

backup -0 -u -f /dev/rmt0 $x >> $BACKUPLOG 2>&1

Not sure if this will work, but let us know.
 
That worked fine.
Thanks very much. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top