[ILUG-BOM] Differential backups with tar.

benoy lists@[EMAIL-PROTECTED]
Fri Feb 24 06:46:22 IST 2006


Nadeem M. Khan wrote:
> Hi.
> 
> I've been trying to get differential backups with tar. I've got it
> working nice and fine except for one problem. If a file is modified
> after the last full backup, it gets included in my differential backup,
> as it should. But my differential backup also includes directories that
> have not been modified since the last full backup. These directories get
> included as empty directories. The files in them (rightly) do not get
> included in the differential. 
> 
> To create a full backup I do:
> 
> tar cvf /backups/full.tar /home
> 
> To create a differential, I use the timestamp of the full backup archive
> as a reference:
> 
> tar cvf /backups/diff.tar --newer="`date -r /backups/full.tar`" /home
> 
> Works well, except for the directory inclusion part. Am I missing
> something?
> 
for differential backups I will suggest rsync
I am running below script by cron job every day
which will create differential backup(daily basis) on current 
folder and moved only changed file to another folder called
changes/`date +%d%m%y`. And verbose mode will generate a 
detailed  report on email every time. And recovery is very easy.

<script>
#!/bin/sh
export PATH=/usr/local/bin:/usr/bin:/bin

BDIR=/path/to/source/folder/
TARGBASE=/backupfolder/current
TARGBASE_PREV=/backupfolder/changes

# excludes file - this contains a wildcard pattern per line of 
files to exclude
EXCLUDES=/path/to/excludes

BACKUPDIR=`date +%d%m%y`
OPTS="--force --ignore-errors --exclude-from=$EXCLUDES --delete 
--backup --backup-dir=$TARGBASE_PREV/$BACKUPDIR -av"

rsync $OPTS "$BDIR" $TARGBASE/current
</script>

Hope this helps and you can find more resource from
http://rsync.samba.org/examples.html

/Benoy




More information about the Linuxers mailing list