Scripting Question - tar
I have this script (stripped down to basics):
#!/bin/bash
sourceDir='/home/' # Directory you're backing up
targetDir='/TERASTATIONBACKUP/GOSHEN/'$(date +%Y) # Destination
directory for the tarball
targFileBase='GoshensHome' # Desired base part of the
tarball's filename
targetFile="$targetDir/`date +%Y-%b-%e`.tgz"
echo "Tarring up source into target"
echo " $targetFile"
tar -czvf - --one-file-system $sourceDir | split -b 2000m $targetFile
The script fails with this output:
Tarring up source into target
/TERASTATIONBACKUP/GOSHEN/2008/2008-Jul-10.tgz
split: cannot open `/TERASTATIONBACKUP/GOSHEN/2008/2008-Jul-10.tgz'
for reading: No such file or directory
tar: Removing leading `/' from member names
But, if I comment out the tar line above and replace it with this line:
tar -cvzf - --one-file-system /home | split -b 2000m -
/TERASTATIONBACKUP/GOSHEN/2008/2008-Jul-10.tgz
the script works.
Am I just not seeing a typo somewhere? Why is my script failing?
Thanks!
--
Kent West <*)))><
http://kentwest.blogspot.com
Reply to: