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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Software required to mount Linux LVM Volume 6 390
File system unmounted 3 155
Problem to command 8 93
incorrect file reading in bash 7 81
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…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

920 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

14 Experts available now in Live!

Get 1:1 Help Now