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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
tallylog file 2 2,600
running two linux commands sequentially in background 16 43
how does yum update work 2 41
Cron jobs 12 91
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…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now