LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-09-2003, 12:31 AM   #1
jlangelier
Member
 
Registered: Jun 2003
Location: Denver, CO
Distribution: Debian
Posts: 95

Rep: Reputation: 15
Tar with --newer option tarring all dirs


Found this great script to backup my linux... it uses tar with the --newer option , and works great, except it includes every directory in the tar file, even if the directory was not changed. (i.e. it includes a list of every directory, but not files, unless the file satisfies the --newer directive)

Makes it hard to peruse the tar file to see what changed between backups. Anyone know how to get tar to not include unchanged directories?



The script follows, not only to illustrate my problem, but because it's a great, simple backup script that I can recommend. Been using it a week now and it works like a charm. Set it to run as a cron job every day, and I get the satisfaction of having a simple, daily backup.

(PS... I know I'm backing up alot of stuff I don't need to... I'll tweak it a bit once I start running out of space on my windows disk or get sick of swapping CD-R's


#!/bin/sh
#
# Excepted from:
# ==============
# Date: 01 May 2001 18:24:21 -0400
# From: Jens Gecius <jens@gecius.de>
# To: jeroen@gecius.de
# Cc: debian-user@lists.debian.org
#
#
# full and incr backup script
# created 27 Sep 99
# Based on a script by Daniel O'Callaghan <danny@freebsd.org>

#Change the 5 variables below to fit your computer/backup

COMPUTER=darkstar # name of this computer
DIRECTORIES="/etc /home /bin /lib /opt /root /sbin /usr /var/log " # directories to backup
BACKUPDIR=/windows/linback # where to store the backups
TIMEDIR=/windows/linback/last-full # where to store time of full backup
TAR=/bin/tar # name and locaction of tar

#You should not have to change anything below here

SRC_CONF=/usr/src/linux/.config
PATH=/usr/local/bin:/usr/bin:/bin
DOW=`date +%a` # Day of the week e.g. Mon
DOM=`date +%d` # Date of the Month e.g. 27
DM=`date +%d%b` # Date and Month e.g. 27Sep

# On the 1st of the month a permanet full backup is made
# Every Sunday a full backup is made - overwriting last Sundays backup
# The rest of the time an incremental backup is made. Each incremental
# backup overwrites last weeks incremental backup of the same name.
#
# if NEWER = "", then tar backs up all files in the directories
# otherwise it backs up files newer than the NEWER date. NEWER
# gets it date from the file written every Sunday.

#mount -o remount,rw /backups

if [ $DOM = "01" ]; then # monthly full backup
NEWER=""
$TAR $NEWER -z -c -f $BACKUPDIR/$COMPUTER-$DM.tgz $DIRECTORIES $SRC_CONF
fi

if [ $DOW = "Sun" ]; then # weekly full backup
NEWER=""
NOW=`date +%d-%b`
echo $NOW > $TIMEDIR/$COMPUTER-full-date #update full backup date
$TAR $NEWER -z -c -f $BACKUPDIR/$COMPUTER-$DOW.tgz $DIRECTORIES $SRC_CONF

else #make incremental backup - overwrite last weeks
NEWER="--newer `cat $TIMEDIR/$COMPUTER-full-date`" #get date of last full backup
$TAR $NEWER -z -c -f $BACKUPDIR/$COMPUTER-$DOW.tgz $DIRECTORIES $SRC_CONF
fi

##mount -o remount,ro /backups
#
# end of file

Last edited by jlangelier; 07-09-2003 at 12:54 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
tar option Paxmaster Linux - Software 1 11-16-2005 06:27 AM
Bash backup script failing using tar and --newer option saldkj Programming 3 03-12-2005 12:03 PM
Newer version of tar? imahdi Linux - Software 1 01-04-2005 08:26 PM
tar -C option ? shanenin Linux - Software 3 07-25-2004 09:36 PM
tar --newer .. or --list-incremental pfunk Linux - Software 1 06-21-2002 02:57 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:25 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration