You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by Chris Jensen <cj...@edex.com.au> on 2005/06/20 03:36:33 UTC

Verifying Backups

Hi,
I've got backups running on my repositories using svn-hot-backup and an 
svnadmin dump --incremental and they seem to be going fine. But to be on 
the safe side, I'd like to have them periodically (say once a week, or 
once a month) verified automatically - ie have a script check that the 
backup dumps can construct a valid repository, and that repository is 
equivalent to the production repository.

How would I go about this - obviously I could simply svnadmin load the 
backups into a new repository and that would verify that they can create 
a repository, but how can I script something to compare it to an 
existing repository? Is this possible?

Regards
Chris

-- 
---------------------------------------------------------------------
Chris Jensen cjensen@edex.com.au

Educational Experience (Australia)
Postal Address: PO Box 860, Newcastle NSW 2300
Freecall:       1-800-025 270      International: +61-2-4923 8222
Fax:            (02) 4942 1991     International: +61-2-4942 1991

Visit our online Toy store! http://www.toysandmore.com.au/
---------------------------------------------------------------------

Re: Verifying Backups

Posted by Vincent Lefevre <vi...@vinc17.org>.
On 2005-06-26 12:01:46 +1000, Chris Jensen wrote:
> Never mind, I figured out a solution:
> 
> HEAD=`svnlook youngest /backup_repos`
> 
> svn ls -R -r $HEAD file:///repos | grep -v "/$" | sort > tree.txt
> svn ls -R -r $HEAD file:///backup_repos | grep -v "/$" | sort |
> 	diff tree.txt - || echo "Backup does not contain all files"
> 
> mknod orig p
> 
> while read file ; do
>       svn cat -r $HEAD "file://repos/$file" > orig &
> 
>       svn cat -r $HEAD "file:///backup_repos/$file" |
> 	diff orig - || echo "$file not backed up correctly"
> done < tree.txt
> 
> This verifies the full content of the HEAD revision in the backup.

But this doesn't check the properties. I wrote the following
script a few weeks ago to compare two repositories at various
revisions (this script can be called in a loop on revision
numbers):

# Checkout a working copy and create .svnlog and .svnprop files.
# Working copies can be compared with "diff -x.svn -r wc1 wc2".

if [ $# -lt 2 ] || [ $# -gt 3 ]; then
  echo "Usage: svnexp <url> <dir> [ <rev> ]" >&2
  exit 1
fi

set -e
url="$1"
dir="$2"
rev="${3:-HEAD}"

if [ -e "$dir" ]; then
  cd "$dir"
  rm -f .svnlog .svnprop
  svn update -r"$rev" --non-interactive --ignore-externals
else
  svn checkout -r"$rev" --non-interactive --ignore-externals "$url" "$dir"
  cd "$dir"
fi

svn log --xml > .svnlog
svn proplist --verbose `svn list -R` > .svnprop

-- 
Vincent Lefèvre <vi...@vinc17.org> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / SPACES project at LORIA

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: Verifying Backups

Posted by Chris Jensen <cj...@edex.com.au>.
Chris Jensen wrote:
> Hi,
> Thanks, to a suggestion that came out of list I'm comparing the result 
> of svn log -r 1:HEAD for the backup and original. This works nicely, but 
> doesn't verify that the actual content of the files is ok.
> 
> I tried doing
> svn diff -r 1:HEAD and comparing the results, however the order that the 
> files are listed in is not consistant so running diff on the output does 
> not work.
> 
> Is there a way to force subversion to stick to an order? Or is there 
> another way of going about this?

Never mind, I figured out a solution:

HEAD=`svnlook youngest /backup_repos`

svn ls -R -r $HEAD file:///repos | grep -v "/$" | sort > tree.txt
svn ls -R -r $HEAD file:///backup_repos | grep -v "/$" | sort |
	diff tree.txt - || echo "Backup does not contain all files"

mknod orig p

while read file ; do
       svn cat -r $HEAD "file://repos/$file" > orig &

       svn cat -r $HEAD "file:///backup_repos/$file" |
	diff orig - || echo "$file not backed up correctly"
done < tree.txt

This verifies the full content of the HEAD revision in the backup.

-- 
---------------------------------------------------------------------
Chris Jensen cjensen@edex.com.au

Educational Experience (Australia)
Postal Address: PO Box 860, Newcastle NSW 2300
Freecall:       1-800-025 270      International: +61-2-4923 8222
Fax:            (02) 4942 1991     International: +61-2-4942 1991

Visit our online Toy store! http://www.toysandmore.com.au/
---------------------------------------------------------------------

Re: Verifying Backups

Posted by Chris Jensen <cj...@edex.com.au>.
Hi,
Thanks, to a suggestion that came out of list I'm comparing the result 
of svn log -r 1:HEAD for the backup and original. This works nicely, but 
doesn't verify that the actual content of the files is ok.

I tried doing
svn diff -r 1:HEAD and comparing the results, however the order that the 
files are listed in is not consistant so running diff on the output does 
not work.

Is there a way to force subversion to stick to an order? Or is there 
another way of going about this?

The only other solution I can see is
svn export
both repositories and do a recursive diff on the results.
I'd prefer not to do this though since I would then need the disk space 
for two copies of the repository.
With svn diff I have an output stream which I can just pipe to diff so I 
don't actually need the disk space - which is preferable.

Regards
Chris

-- 
---------------------------------------------------------------------
Chris Jensen cjensen@edex.com.au

Educational Experience (Australia)
Postal Address: PO Box 860, Newcastle NSW 2300
Freecall:       1-800-025 270      International: +61-2-4923 8222
Fax:            (02) 4942 1991     International: +61-2-4942 1991

Visit our online Toy store! http://www.toysandmore.com.au/
---------------------------------------------------------------------