Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Incremental Backups And Full Backups

Posted on 2004-04-29
7
Medium Priority
?
238 Views
Last Modified: 2010-04-22
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
0
Comment
Question by:gavinw007
  • 3
  • 2
5 Comments
 
LVL 22

Expert Comment

by:NovaDenizen
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
0
 

Author Comment

by:gavinw007
ID: 10958159
Hi,

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

Gav
0
 
LVL 22

Accepted Solution

by:
NovaDenizen earned 300 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.


0
 

Author Comment

by:gavinw007
ID: 10995870
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
0
 
LVL 22

Expert Comment

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

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

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 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…
Integration Management Part 2
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

773 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