[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

svn as backupsolution: problem with dirs

From: alexander poddey <alexander.poddey_at_tu-clausthal.de>
Date: 2005-12-07 08:52:55 CET


I introduced a backupsystem which combines unison and svn. See the description
below. I plan to provide it for free on my homepage as soon as it is stable.

short description of my problem:
if a user deletes a directory and reintroduces it (rm -rf dir1 && mkdir dir1),
which happens e.g. if i import dir1 in another svnrepository (i have to
delete dir1 afterwards and check it out from the newrepository), the backup
svn repository gets in trouble.
this is because the dir1 seems to be already under version control, but if i
enter in dir1 and try to svn add a file, svn notices, that the dir1 is not
under version control (the formerly existing .svn was deleted by the user).

a bit complicated?
ok, here is how you can reproduce the error:

mkdir testsvn
cd testsvn && mkdir dir1 && touch dir1/file1
cd ..
svn import testsvn file:////path/to/a/testrepository/testsvn
rm -rf testsvn
svn co file:////path/to/a/testrepository/testsvn testsvn
#up to here, everything is ok

#--- now comes the evil ---
rm -rf testsvn/dir1 && mkdir testsvn/dir1 && touch testsvn/dir1/file2
cd testsvn
svn status # ~ dir1
svn add dir1 #... already under version control
cd dir1 && svn add file2 # ...not a working copy

the only solution i found was:
svn rm file:////path/to/a/testrepository/testsvn/dir1
mv dir1 /tmpoutsidetheworkincopy/dir1
svn update
mv /tmpoutsidetheworkincopy/dir1 dir1
svn add dir1

I don't like this, because it makes the backupprocess even more complicated.
Isn't there a possibility to tell svn that it should check (during add) if it
is the same directory/file, and if not 'resolve' the problem?
something like svn add --check/update dir1?
I did some tests with --force, without success.

any suggestions?

many thanks.

p.s.: I will announce the release of the backupscript here.
If anyone is interested to see it before, she/he should contact me.

# Why such a combination of unison and svn?
# svn handles the files in binary mode and incremental. In principle, it
# is an optimal backupsystem. The only problem is that, if the backed up
# filesystem contains svn versioned directories, one get's conflicts while
# trying to import that directory into a backup repository.
# The combination of unison ,subversion and a little shell scripting
# can overcome this problem.

# How it works:
# unison allows to mirror a filesystem. We do this UNIdirectional
# from source to target (sync.sh). This ensures that the original
# files are not changed, and allows to handle the user's svn directories.
# The script add_commit.sh works on the mirrored files. It moves the users
# .svn directories to .svn_user and the .svn_backup directories, which are
# only present in the mirror filesystem to .svn.
# The latter keep the information about the backup repository.
# After adding all new files, the script triggers a svn commit and
# copies the .svn directories back (.svn -> .svn_backup, .svn_user -> .svn)
# The user can then acces the unison mirror directly or get any revision
# from the svn repository.

# User side control:
# Per default, all files and directories in source will be backed-up (except
# files set to ignore [see above]).
# I allow the user to control the backupprocess by hidden files.
# .ignore ignores all files in the actual directory
# .ignorer ignores all files in the actual and lower directories
# .add overrides .ignorer in the actual directory
# .addr adds all files in the actual and all lower directories
# subsequent use of .ignorer and .addr allows flexibly to 'hide' parts
# of the source. Nevertheless, the directory structure is backed up (the
# ignored directories contain no files, but the lower directories).
# This means that you can switch from .ignore to .add and vice versa
# as often as you like.

Alexander Poddey
Institute of Theoretical Physics      
Clausthal University of Technology  
Leibnizstr. 10                              
38678 Clausthal-Zellerfeld                
Tel:    +49(5323)72 2580                   
FAX:    +49(5323)72 3116                   
E-MAIL: alexander.poddey@tu-clausthal.de    
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Wed Dec 7 10:02:16 2005

This is an archived mail posted to the Subversion Users mailing list.