bug-tar
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-tar] --listed-incremental fails to archive old files in new directo


From: Martin Simmons
Subject: [Bug-tar] --listed-incremental fails to archive old files in new directories
Date: Sun, 27 Jun 2004 00:03:15 +0100 (BST)

Hi there,

I think there is a bug in the logic behind the change src/create.c 1.79.  The
log says:

> 1) when incremental_option==1
> This means incremental backup in progress. In this case dump_file
> is invoked only for directories or for files marked with 'Y' by
> get_directory_contents. The latter are those that did not meet the
> condition in incremen.c:242, which is exactly the same condition
> as this at create.c:1296...

The problem is that there is an extra case where the condition in
incremen.c:242 is not met, namely when children is not CHANGED_CHILDREN.  This
can happen when the code at incremen.c:211 set it to ALL_CHILDREN while
processing the parent directory.

E.g. the test script below fails to archive c2/ca1 and c2/ca2 and hence they
are lost afer the incremental restore :-(

---------------------------------- tart.sh -----------------------------------
#! /bin/csh -f

tar --version

rm -f tart.tar1 tart.incr1
rm -f tart.tar2 tart.incr2
rm -rf tart tart-new

echo Create directories
mkdir tart
sleep 1
mkdir tart/c0
sleep 1
mkdir tart/c1
sleep 1
foreach file (tart/a1 tart/b1 tart/c0/cq1 tart/c0/cq2 tart/c1/ca1 tart/c1/ca2)
  echo File $file > $file
  echo Created $file
  sleep 1
end

sleep 1
echo Creating main archive
tar -c -v --listed-incremental=tart.incr1 -f tart.tar1 tart

sleep 1
echo Modifying filesystem
rm tart/a1
mv tart/b1 tart/b2
mv tart/c1 tart/c2
touch tart/c2/ca3

sleep 1
echo Creating incremental archive
cp -p tart.incr1 tart.incr2
tar -c -v --listed-incremental=tart.incr2 -f tart.tar2 tart

sleep 1
mkdir tart-new
cd tart-new
echo Extracting main archive
tar -x -v --listed-incremental=tart.incr1 -f ../tart.tar1
echo Extracting incremental archive
tar -x -v --listed-incremental=tart.incr2 -f ../tart.tar2

echo Final files:
find . -print

------------------------------------------------------------------------------


The output of the script is
------------------------------------------------------------------------------
tar (tar) 1.14.1
Create directories
Created tart/a1
Created tart/b1
Created tart/c0/cq1
Created tart/c0/cq2
Created tart/c1/ca1
Created tart/c1/ca2
Creating main archive
tar: tart/c0: Directory is new
tar: tart/c1: Directory is new
tart/
tart/c0/
tart/c1/
tart/a1
tart/b1
tart/c0/cq1
tart/c0/cq2
tart/c1/ca1
tart/c1/ca2
Modifying filesystem
Creating incremental archive
tar: tart/c2: Directory is new
tart/
tart/c0/
tart/c2/
tart/b2
tart/c2/ca3
Creating incremental archive again
tar: tart/c2: Directory is new
tart/
tart/c0/
tart/c2/
tart/b2
tart/c2/ca3
Extracting main archive
tart/
tart/c0/
tart/c1/
tart/a1
tart/b1
tart/c0/cq1
tart/c0/cq2
tart/c1/ca1
tart/c1/ca2
Extracting incremental archive
tart/
tar: Deleting `tart/c1'
tar: Deleting `tart/a1'
tar: Deleting `tart/b1'
tart/c0/
tart/c2/
tart/b2
tart/c2/ca3
Final files:
.
./tart
./tart/c0
./tart/c0/cq1
./tart/c0/cq2
./tart/c2
./tart/c2/ca3
./tart/b2
------------------------------------------------------------------------------


Putting back the test for incremental_option fixes the problem (but no doubt
breaks the incremental archiving of individual files again).  Possibly
collect_and_sort_names should be handling these, removing individual files
from namelist if they shouldn't be archived?

------------------------------------------------------------------------------
diff -u -r1.85 create.c
--- src/create.c        26 Apr 2004 09:19:07 -0000      1.85
+++ src/create.c        26 Jun 2004 22:44:29 -0000
@@ -1303,9 +1303,12 @@
 #endif
 
   /* See if we want only new files, and check if this one is too old to
-     put in the archive.  */
+     put in the archive.  For incremental archives, scan_directory has
+     already made the decision based on more accurate information than
+     we have here (in particular for old files in new directories). */
 
-  if (!S_ISDIR (st->stat.st_mode)
+  if (!incremental_option
+      && !S_ISDIR (st->stat.st_mode)
       && OLDER_STAT_TIME (st->stat, m)
       && (!after_date_option || OLDER_STAT_TIME (st->stat, c)))
     {
------------------------------------------------------------------------------

__Martin




reply via email to

[Prev in Thread] Current Thread [Next in Thread]