I had a similar problem when writing my back-up script. I too did the 2>&1, but it did not the effect that both stdout and stderr were written to my logfile.
This code does it:
do
star -diff -vv f=$dumpdevice -C $dir . 2>>$logfilename
done >>$logfilename
The output of stderr goes to the log file because of the 2>>$logfilename.
The output of stdout goes to the log file because of
do
[..]
done >> $logfilename
Don't ask me why. Sometimes I think that the designers of Bash wrote the interpreter, and discovered afterwards how some command turned out to work.
BTW, why do you export LOGFILE=/root/logs/backup.log? Just LOGFILE=/root/logs/backup.log should be enough for this script. Or maybe I don't understand it at all and that is why I had to use this workaround in my own script anyway.
You can find the entire script
here . It is not perfect, but it is useful. It does nice logging of both the events and provides a full list of backed-up files.
jlinkels