Link to home
Start Free TrialLog in
Avatar of gavinw007
gavinw007

asked on

Incremental Backups And Full Backups

Hi,

I have created a script to do incremental backups as per below...

#!/bin/bash

days=1
dmy=$(date +%d%m%Y)

cd /test

find /home -mtime -$days -print | tar zvcf /test/backup.${dmy}.${days}.tgz -T -

This works fine BUT for some reason it makes 2 extra copies and i cant figure out why so in my backkup.tgz file i see...

/home/joe/data
/home/joe/data

Which is making my backups double the size, has anyone got any solutions as to why this is happening? or have they got a better way of doing incremental then a full backup?

Thanks for any assistance!

Gav
Avatar of NovaDenizen
NovaDenizen

Easy.  One of the lines output by your find command is "/home/joe", so tar recurses down the entire /home/joe subdirectories and puts everything into the tar file, including /home/joe/data.  Later on, the find command outputs "/home/joe/data".  tar doesn't realize that it has already put this subdirectory into the tar file, so it goes ahead and sends /home/joe/data and its contents into the tar file for a second time.

Both find and tar are recursing through the directories.  From the tar manpage, "The use of a directory name always implies that the subdirectories below should be included in the archive".  Using find for directories might not be the best idea here.

Some gnu tar options you might want to look at:
-G, --incremental : create/list/extract old GNU-format incremental backup
-g, --listed-incremental F : create/list/extract new GNU-format incremental backup
-N, --after-date DATE, --newer DATE: only store files newer than DATE
Avatar of gavinw007

ASKER

Hi,

could you kindly post an example, as im having alot of problems :-) sorry for being a newbie!

Gav
ASKER CERTIFIED SOLUTION
Avatar of NovaDenizen
NovaDenizen

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi,

Sorry for delay... I have tried the above dump commands i can do that fine but for some reason i cannot use the restore to restore my file, have check out the man pages but it seems to be looking for a tape drive.

Think we are nearly there tho

Thanks again :-)

Gav
I think you need to use the -A option to tell it where to find your dump files.  Have you tried that?