cancel
Showing results for 
Search instead for 
Did you mean: 

backup script

mohammed abdul jaleel
Occasional Contributor

backup script

i want to take a backup of whole unix server 11i.v3 when i execute the script it is giving me error
tar: n: unknown option
tar: usage tar [-]{txruc}[eONvVwAfblhm{op}][0-7[lmh]] [tapefile] [blocksize] [[-C directory] file] ...

i have attach the script can u please check the script and help me thanks
3 REPLIES
Jose Mosquera
Honored Contributor

Re: backup script

Hi,

Meanwhile I review your script please please execute it again ussing a trace option:
#sh -x
This option helps you to follow the execution sequence and find issues.

A first recomendation, when you compares variables inside an if ensures that both are the same type (alphanumeric or numeric), in your case, these:
if [ $DOM = "01" ];
if [ $DOW = "Thu" ];
for these:
if [ "$DOM" = "01" ];
if [ "$DOW" = "Thu" ];

Never mind that "01" looks a numeric value, you are force it to compare character by character with the other variable value.

Please execute the trace...

Rgds.
Jose Mosquera
Honored Contributor

Re: backup script

Hi,

Check your "else" section (Get date of last full backup):
NEWER="--newer `cat $TIMEDIR/$COMPUTER-full-date`"
$TAR $NEWER -cf $BACKUPDIR/$COMPUTER-$DOW.tar $DIRECTORIES

So the tar message:
tar: n: unknown option

The content of $NEWER beggins with "--n", then "tar" command interprets this an invalid option.

Whats is the sense of $NEWER here?

Rgds.
Dennis Handly
Acclaimed Contributor

Re: backup script

You need to use gnu tar to support --newer:
http://www.gnu.org/software/tar/manual/tar.html#SEC114

Otherwise you can use find and pax(1).