Article 53YSQ tar Incremental Backup Not Working

tar Incremental Backup Not Working

by
gw1500se
from LinuxQuestions.org on (#53YSQ)
I've written a bash script that does tar incremental backup on specific directories. A full backup works fine. I don't know what I'm doing wrong but when I specify an incremental backup, a full backup is done instead in the incremental directory. Perhaps some new eyes can see what I am missing. TIA.

Code:#!/bin/bash
#
# backup for git and pit user directories
#
user=`whoami`
if [ "$user" != "root" ] ; then
echo "must be run as root (sudo)"
exit -1
fi
if [ `mount|grep /Backups|wc -l` -ne 1 ] ; then
echo "Mounting backup share"
mount /Backups
if [ `mount|grep /Backups|wc -l` -ne 1 ] ; then
echo "Backup skipped - backup share cannot be mounted"
exit -1
fi
fi
DIR1=/home/pi
DIR2=/home/git
DIR3=/usr/local/bin
META1=/Backups/pi.sngz
META2=/Backups/git.sngz
META3=/Backups/usr.sngz
DATE=$(date +%-Y%-m%-d)-$(date +%-T)
if [ $# -gt 0 ] ; then
TYPE=$1
else
TYPE="full"
fi
if [[ "$TYPE" == "full" || "$TYPE" == "incremental" ]] ; then
echo "Backup type is $TYPE"
else
echo "Usage: $0 full|incremental"
exit -1
fi
if [ "$TYPE" == "full" ] ; then
rm $META1
rm $META2
rm $META3
rm /Backups/full/*
rm /Backups/incremental/*
fi
OUTDIR=$1
OUT1=/Backups/$OUTDIR/pi-$DATE.tgz
OUT2=/Backups/$OUTDIR/git-$DATE.tgz
OUT3=/Backups/$OUTDIR/usr-$DATE.tgz
echo "Backing up $DIR1 to $OUT1"
tar --listed-incremental=$META1 -czf $OUT1 $DIR1
echo "Backing up $DIR2 to $OUT2"
tar --listed-incremental=$META2 -czf $OUT2 $DIR2
echo "Backing up $DIR3 to $OUT3"
tar --listed-incremental=$META3 -czf $OUT3 $DIR3latest?d=yIl2AUoC8zA latest?i=SXT-GyajjLo:yy3gzRR_7ew:F7zBnMy latest?i=SXT-GyajjLo:yy3gzRR_7ew:V_sGLiP latest?d=qj6IDK7rITs latest?i=SXT-GyajjLo:yy3gzRR_7ew:gIN9vFwSXT-GyajjLo
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments