- if `ssh $computer "cd $filesystem ;\
- tar cfl - . $forrigecmd \
- --exclude-from=$exclude \
- | gzip" \
- | dd of=$DATE.tmp 2>/dev/null`
- then
- #Det gikk kanskje bra
- mv $DATE.tmp $DATE.tgz
- #lage listefil
- tar tvfz $DATE.tgz > $DATE.idx 2>&1
- grep -v ^d $DATE.idx | sort -n -r +2 > $DATE.sdx
+ #if this client has a special tar
+ #we need to find a better solution to this conf-issue
+ if [ -f $confdir/tar.$computer ] ; then
+ tar=`cat $confdir/tar.$computer`
+ else
+ tar=tar
+ fi
+
+ # expand the exclude-path for use with tar
+ exf=`ssh root@$computer "ls ~/.backup/exclude"`
+
+ # We try to run tar on the remote computer
+ # z gzip it
+ # c create archive
+ # C change to directory first
+ # . where to start taring (see C)
+ # $lastcmd only files newer than this
+ # --one-file-system don't traverse file systems
+ # --exclude-from file to get exclusion pattern from
+ # Pipe the stuff over ssh to ourselves, run pee to cat the contents to a
+ # file and build a file list, respectivly.
+ TARFILE=$DATE.tmp
+ TARCMD="ssh root@$computer \"$tar --one-file-system -zcf - -C $filesystem . $lastcmd \
+ --exclude-from=$exf\" | pee \"cat > $TARFILE\" \"tar tvf -\""
+ echo `date`" $computer: Running $TARCMD" >&2
+ eval $TARCMD > $DATE.idx
+
+ if [ -s $TARFILE ]; then
+ # File is >0 in size, we assume it worked.
+
+ # Move tar file in place
+ mv $TARFILE $DATE.tgz
+
+ # Update timestamp
+ echo $DATEs > ../.date && touch -t $DATE ../.date