1845529 Members
181 Online
110244 Solutions
New Discussion

fbackup

 
SOLVED
Go to solution
Jose Mosquera
Honored Contributor

fbackup

Hi,

I'm trying to make a root's cron scheduled script with the following features:

1.- Redirect default the cron of root's mail output to a specific file.
2.- Take the final command fbackup status ($?) to evaluate a specific action inside of the script.

I'm doing this by the following piped commands:

fbackup -0 -v -i / -f /dev/rmt/0m 2>&1|tee /
STATUS=$?

With this I am achieving redirect the cron fbackup output to / instead of /var/mail/root file, but when immediately I ask for the status ($?), it is always shown me the status value of the "tee" command instead of the "fbackup" command, being always status zero. Some recommendation in this respect?

Regards
6 REPLIES 6
Darren Prior
Honored Contributor

Re: fbackup

Hi,

I think the easy way out of this problem is to remove the tee command and just redirect the output of fbackup to a file, ie:

fbackup -0 -v -i / -f /dev/rmt/0m 2>&1 >whatever
STATUS=$?

This allows STATUS to reflect fbackup's return code. Tee does 2 things, it sends stdin to the output file plus it also sends stdin to stdout, which I don't believe is needed here.

regards,

Darren.
Calm down. It's only ones and zeros...
Jose Mosquera
Honored Contributor

Re: fbackup

Darren,

I've tried your recomendation before, but didn't work fine, the file "whatever" just is created with cero file size. Just try with a little test situation, i.e:

fbackup -0 -v -i / -f /tmp/ 2>&1 > /tmp/fback.log;echo $?

The $? variable are ok but /tmp/fback.log is empty!

Rgds.
Frank Slootweg
Honored Contributor
Solution

Re: fbackup

Standard out of fbackup is *not* used for *messages*, but only for the archive (if "-f -" is used, otherwise standard out is not used at all).

*All* messages, i.e. both normal and error messages go to standard error, so you only have to re-direct standard error, i.e. "2>/path/somefile".

Note: tar and cpio also do this, and so does *frecover* just for 'symmetry'.
monasingh_1
Trusted Contributor

Re: fbackup

I think you should use -V FILENAME option as well and then the "FILENAME" will only be created if the backup is successful. you do not need to depend on $?...

hope this works for you..
Michael Tully
Honored Contributor

Re: fbackup

Not sure if this is too late for you, but I've attached an 'fbackup' script that you run from cron. I use it here on special systems that I can't use OmniBack on.

HTH
Michael
Anyone for a Mutiny ?
Frank Slootweg
Honored Contributor

Re: fbackup

I would not rely too much on the "-V filename" method, because, in the context of fbackup, "successful" is a relative term, i.e. what does it do for exit codes (RETURN VALUE) 1 and 4, and what does that mean for *you*?