Solved

Incremental Backups And Full Backups

Posted on 2004-04-29
7
227 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
7 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 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.


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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Mounting Linux Partition.... 30 349
How to import linux vhd to sccvmm 1 154
Avoiding pop-up when starting a linux scrip/shell 5 104
Why  my code (program) build with old compiler? 11 45
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…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

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