Having issues with compressing folders via tar on shell backup script.
# Path to backup directories
DIRS="/home/bob /var/www /root"
# Store todays date
NOW=$(date +"%F")
# Store backup path
BACKUP="/backup"
BACKUPDIR="$BACKUP/daily/calendar/$NOW"
# Backup file name hostname.time.tar.gz
BFILE="dirs.tar.gz"
$TAR -zcvf ${BACKUPDIR}/${BFILE} "${DIRS}"
echo $TAR -zcvf ${BACKUPDIR}/${BFILE} "${DIRS}"
The error I keep getting is
/bin/tar: Removing leading `/' from member names
/bin/tar: /home/bob /var/www /root: Cannot stat: No such file or directory
/bin/tar: Exiting with failure status due to previous errors
/bin/tar -zcvf /backup/daily/calendar/2012-12-13/dirs.tar.gz /home/bob /var/www /root
If i run the last echo command on terminal, it works ok. Does not work when called within the script
Try to remove the double quotes: