On 08/07/2011 13:30, abschiedsstein wrote:
Hi,
I used rdiff-backup for a while and everything was fine. Backups were fast and
restoring was no problem.
Then, after an interrupted backup, the data was broken. Neither restoring nor
fixing with --check-destination-dir was possible.
I guess there is somekind of a standard routine to fix this, but I was not able
to figure it out until now.
Before I get into details, here are some information about my machine.
OS: Ubuntu 10.10
rdiff-backup: rdiff-backup 1.2.8
The backup directory is on an external usb drive.(NTFS)
When I tried to restore a file I got the message that the last backup was interrupted and that I
should run --check-destination-dir (so far, so good). I did this. There were many messeges like
"... metadata, but could not be constructed from existing increments because last increment
had type ..." . When I now run --check-destination-dir again, I get : "Fatal Error:
Destination dir /media/TREKSTOR/Sicherungen/neodata-backup/home does not need checking". BUT
restoring is still not possible:
rdiff-backup -r now /media/TREKSTOR/backupdir/Desktop/protokoll.pdf
Desktop/proto.pdf
Warning: Could not restore file .!
A regular file was indicated by the metadata, but could not be
constructed from existing increments because last increment had type
dir. Instead of the actual file's data, an empty length file will be
created. This error is probably caused by data loss in the
rdiff-backup destination directory, or a bug in rdiff-backup
I would like to know a way to fix the backup. It would be completely sufficient
if everything since the last successful backup would be deleted.
I hope someone can help me. Thanks in advance.
I attach a bash script which automates the process of forcibly regressing an
rdiff-backup repository. You can use this to override the 'does not need
checking' message.
Help is built in, just run the script without parameters to see. It does
a single step regression, it can be run multiple times if you need to
regress the repository back further. All the usual caveats apply.
Dominic
#!/bin/bash
THIS=`basename $0`
COLUMNS=$(stty size 2>/dev/null||echo 80); COLUMNS=${COLUMNS##* }
while getopts ":qfh" optname; do
case "$optname" in
"f")FORCE="y";;
"q")QUIET="y"; RDIFFBACKUPOPTIONS="--terminal-verbosity 0";;
"h")HELP="y";;
"?")echo "Unknown option $OPTARG"; exit 1;;
":")echo "No argument value for option $OPTARG"; exit 1;;
*) # Should not occur
echo "Unknown error while processing options"; exit 1;;
esac
done
shift $(($OPTIND-1))
if [ -z "$QUIET" -o -n "$HELP" -o -z "$1" ]; then
echo -en "\n$THIS v0.1216 by Dominic domi...@timedicer.co.uk"
[ -z "$HELP" -a -n "$1" ] && echo -n " (-h for help)"
echo -e "\n${THIS//?/=}\n"
fi
if [ -n "$HELP" -o -z "$1" ]; then
echo -e "Forces regression of an rdiff-backup archive even if natural
regression does not occur. Can be useful if a repository is corrupted and
regression is neither automatic nor can be initiated with
--check-destination-dir.\n\nUsage: \t$THIS [options] archive-path\nExample:
\t$THIS -f /home/fred/backup\nOptions:\tf - Force, proceed with no
prompt\n\t\th - Help, this help text\n\t\tq - Quiet, no output unless
error\n"|fold -s -w $COLUMNS
exit
fi
if [ ! -d "$1" ]; then
echo "Cannot find directory \"$1\", aborting..."
exit 1
fi
ARCHIVE=$1
if [ ! -d "$ARCHIVE/rdiff-backup-data" ]; then
echo "$ARCHIVE does not appear to be a valid rdiff-backup repository,
aborting..."
exit 1
fi
[ -z "$QUIET" ] && echo "Using repository: $ARCHIVE"
WHENLAST=`ls $ARCHIVE/rdiff-backup-data/current_mirror*|sed
's/.*current_mirror\.\([^.]*\).*/\1/'`
NUMCURRENT=`echo $WHENLAST|awk '{print NF}'`
if [ $NUMCURRENT -ne 2 ]; then
if [ $NUMCURRENT -ne 1 ]; then
echo "$NUMCURRENT current_mirror files, aborting..."
exit 1
else
[ -z "$QUIET" ] && echo "rdiff-backup does not recognise this
repository as damaged"
fi
else
[ -z "$QUIET" ] && echo "rdiff-backup recognises this repository as
damaged"
fi
PREVRUN=`ls $ARCHIVE/rdiff-backup-data/mirror_metadata*|tail -n2|head -n1|sed
's/.*mirror_metadata\.\([^.]*\).*/\1/'`
if [ -z "$FORCE" ]; then
read -n 1 -t 30 -p "About to regress $ARCHIVE repository from $WHENLAST
to $PREVRUN: ok (y/-)? "
[ "$REPLY" != "y" ] && echo " - aborting..." && exit 1
fi
[ -z "$QUIET" ] && echo -e "\nStarted `date`"
if [ $NUMCURRENT -eq 1 ]; then
cp -a "$ARCHIVE/rdiff-backup-data/current_mirror.$WHENLAST.data"
"$ARCHIVE/rdiff-backup-data/current_mirror.$PREVRUN.data"
[ -z "$QUIET" ] && echo "Copied current_mirror"
fi
[ -z "$QUIET" ] && echo "Regressing, this may take a long time, please be
patient..."
rdiff-backup $RDIFFBACKUPOPTIONS --check-destination-dir $ARCHIVE
[ -z "$QUIET" ] && echo "Ended `d