||10-26-2009 12:37 PM
tar backup Bash script help
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.
exec > $LOGFILE 2>&1
echo "Starting backup of $BUDIR to file $OUTPUT"
if [ `date +%w` -eq 4 ] ; then
tar -cvzpf $OUTPUT $BUDIR
if [ `date +%w` -gt 0 ] && [ `date +%w` -lt 4 ]; then
test -f $OUTPUT && find $BUDIR -type f -newer $OUTPUT | tar --null -czvf $OUTPUT -T-
if [ $? == 0 ]; then
mail -s "Backup successful for $OUTPUT" oj < $LOGFILE
mail -s "Backup failed for $OUTPUT" oj < $LOGFILE
The error I get is
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...