0
遇到在shell備份腳本上通過tar壓縮文件夾的問題。Shell腳本tar錯誤
# 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}"
我不斷收到的錯誤是
/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
如果我在終端上運行的最後一個echo命令,它工作正常。當腳本
奏效。謝謝] – bobsr