#648048 tar: incremental restore fails when a directory is renamed as a name of a deleted directory

Package:
tar
Source:
tar
Description:
GNU version of the tar archiving utility
Submitter:
Piviul
Date:
2011-11-12 17:54:05 UTC
Severity:
important
#648048#5
Date:
2011-11-08 15:59:37 UTC
From:
To:
I have done a bash script to shows the bug:

#!/bin/sh

dirtest=tartest
if [ -d "$dirtest" ]; then
    echo please delete the folder $dirtest or change the variable dirtest in
this script.
    exit 1
fi

# create dir1/file1
mkdir -p "$dirtest/dir1"
touch "$dirtest/dir1/file1"

# create dir2/file1
mkdir "$dirtest/dir2"
touch "$dirtest/dir2/file1"

# incrememental 0
tar cz -g "$dirtest"0 -f "$dirtest"0.tgz "$dirtest"

# delete of dir1
rm -rf "$dirtest/dir1"

# move of dir2 in dir1
mv "$dirtest/dir2" "$dirtest/dir1"

# incremental 1
cp "$dirtest"0 "$dirtest"1
tar cz -g "$dirtest"1 -f "$dirtest"1.tgz "$dirtest"

# remove of dirtest
rm -rf "$dirtest"

# restore from tar
tar xz -g /dev/null -f "$dirtest"0.tgz
tar xz -g /dev/null -f "$dirtest"1.tgz

#648048#10
Date:
2011-11-09 11:58:07 UTC
From:
To:
I have modified the script to use snar on restore but doesn't works too.

This is the new script:

#!/bin/sh

dirtest=tartest
if [ -d "$dirtest" ]; then
    echo please delete the folder $dirtest and old tar \
         or change the variable dirtest in this script.
    exit 1
fi

# create dir1/file1
mkdir -p "$dirtest/dir1"
touch "$dirtest/dir1/file1"

# create dir2/file1
mkdir "$dirtest/dir2"
touch "$dirtest/dir2/file1"

# incrememental 0
tar cz -g "$dirtest"0.snar -f "$dirtest"0.tgz "$dirtest"

# delete of dir1
rm -rf "$dirtest/dir1"

# move of dir2 to dir1
mv "$dirtest/dir2" "$dirtest/dir1"

# incremental 1
cp "$dirtest"0.snar "$dirtest"1.snar
tar cz -g "$dirtest"1.snar -f "$dirtest"1.tgz "$dirtest"

# remove of dirtest
rm -rf "$dirtest"

# restore from tar
tar xz -g "$dirtest"0.snar -f "$dirtest"0.tgz
if [ $? -gt 0 ]; then
    echo restore 0 failed
    exit 1
fi
tar xz -g "$dirtest"1.snar -f "$dirtest"1.tgz
if [ $? -gt 0 ]; then
    echo restore 1 failed
    exit 1
fi

#648048#17
Date:
2011-11-12 17:50:10 UTC
From:
To:
tags 648048 +upstream
thanks