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
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
tags 648048 +upstream thanks