Guys I need help finding out why my backup script is not working as it should. The problem exists in the second if statement, and the second problem is in the differential backup line itself.
Code:
#!/bin/bash
OUTPUT=/home/oj/Desktop/backup_$(date +%Y%m%d).tar.gz
BUDIR=/home/oj/Documents/
LOGFILE=/home/oj/Desktop/backup_$(date +%Y%m%d).log
exec > $LOGFILE 2>&1
echo "Starting backup of $BUDIR to file $OUTPUT"
if [ `date +%w` -eq 4 ] ; then
tar -cvzpf $OUTPUT $BUDIR
fi
if [ `date +%w` -gt 0 ] && [ `date +%w` -lt 4 ]; then
test -f $OUTPUT && find $BUDIR -type f -newer $OUTPUT | tar --null -czvf $OUTPUT -T-
fi
if [ $? == 0 ]; then
mail -s "Backup successful for $OUTPUT" oj < $LOGFILE
else
mail -s "Backup failed for $OUTPUT" oj < $LOGFILE
fi
The error I get is
Code:
Starting backup of /home/oj/Documents/ to file /home/oj/Desktop/backup_20091027.tar.gz
tar: Removing leading `/' from member names
tar: /home/oj/Documents/backup\n: Cannot stat: No such file or directory
tar: Exiting with failure status due to previous errors
If I hash out the first if statement along with the tar line and the second if statement, in other words, just let the differential backup run, I get the same error as above.
Whats the problem? I'm new at this...