Incremental Backups And Full Backups

Posted on 2004-04-29
Last Modified: 2010-04-22

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


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...


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!

Question by:gavinw007
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
LVL 22

Expert Comment

ID: 10952150
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

Author Comment

ID: 10958159

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

LVL 22

Accepted Solution

NovaDenizen earned 75 total points
ID: 10959832
One thing you could do is exclude the directories from the tar file.  

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

I think it may be impossible to make tar add a directory to an archive without also archiving the contents of that directory, so maybe tar is not the tool for the job.  

Have you looked at the 'dump' and 'restore' commands?  They comprise a fairly comprehensive backup system, and can support 10 separate arbitrary levels of incremental backups.  

To do a complete backup, you run:
dump -0 -f /test/home0.dump /home

Then, to do an incremental backup later, run
dump -5 -f /dest/home5.dump /home

When you do a level 0 backup, it unconditionally backs up all files.  When you do a level N backup, where N is greater than zero, it backs up all files that were modified or created since the last dump at a level N-1 or less.


Author Comment

ID: 10995870

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 :-)

LVL 22

Expert Comment

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

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : All lightning effects with instructions : http://www.mediaf…

632 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question