Skip to content
Snippets Groups Projects
svn 1.91 KiB
Newer Older
  • Learn to ignore specific revisions
  • # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*-
    
    elijah's avatar
    elijah committed
    #
    # this handler will backup subversion repostitories.
    #
    
    getconf src /var/lib/svn
    getconf dest /var/backups/svn
    getconf tmp /var/backups/svn.tmp
    
    getconf HOTBACKUP "/usr/bin/svnadmin hotcopy"
    
    micah's avatar
    micah committed
    getconf vsname	
    
    elijah's avatar
    elijah committed
    
    error=0
    
    micah's avatar
    micah committed
    
    # If vservers are configured, decide if the handler should
    # use them or if it should just operate on the host
    
    if [ "$vservers" = "yes" ]
    
    micah's avatar
    micah committed
    then
    	if [ ! -z $vsname ]
    	then		
    		info "Using vserver '$vsname'"
    		usevserver=1
    	else
    		info "No vserver name specified, actions will be performed on the host"
    	fi
    fi
    
    
    # If needed, make sure that the specified vserver exists and is running.
    
    micah's avatar
    micah committed
    if [ $usevserver ]
    then
    
    	info "examining vserver '$vsname'"
            # does it exist ?
    
    micah's avatar
    micah committed
    	vroot="$VROOTDIR/$vsname"
    	[ -d $vroot ] || fatal "vserver '$vsname' does not exist at '$vroot'"
    
            # is it running ?
    	running=`$VSERVERINFO $vsname RUNNING`
    
    	[ "$running" = "1" ] || fatal "vserver $vsname is not running."
    
    micah's avatar
    micah committed
    fi
    
    cd $vroot$src
    
    elijah's avatar
    elijah committed
    for repo in `find . -name svnserve.conf`
    do
        repo=`dirname $repo`
        repo=`dirname $repo`
    
    
    micah's avatar
    micah committed
        ret=`mkdir -p $vroot$tmp/$repo 2>&1`
    
    elijah's avatar
    elijah committed
        code=$?
        if [ "$ret" ]; then
           debug "$ret"
        fi
        if [ $code != 0 ]; then   
    
    micah's avatar
    micah committed
           error "command failed mkdir -p $vroot$tmp/$repo"
    
    elijah's avatar
    elijah committed
        fi
    
    
    micah's avatar
    micah committed
        if [ $usevserver ]
        then
    	ret=`$VSERVER $vsname exec $HOTBACKUP $src/$repo $tmp/$repo 2>&1`
        else
    	ret=`$HOTBACKUP $src/$repo $tmp/$repo 2>&1`
        fi
    
    elijah's avatar
    elijah committed
        code=$?
        if [ "$ret" ]; then
           debug "$ret"
        fi
        if [ $code != 0 ]; then
    
    micah's avatar
    micah committed
           error "command failed -- $HOTBACKUP $vroot$src/$repo $vroot$tmp/$repo"
    
    elijah's avatar
    elijah committed
           error=1
        fi
    done
    
    
    if [ $error -eq 1 ]; then
    
    micah's avatar
    micah committed
        echo "Error: because of earlier errors, we are leaving svn backups in $vroot$tmp instead of $vroot$dest"
    
    elijah's avatar
    elijah committed
    else
    
    micah's avatar
    micah committed
        if [ -d $vroot$dest -a -d $vroot$tmp ]; then
            rm -rf $vroot$dest
    
    elijah's avatar
    elijah committed
        fi
    
    micah's avatar
    micah committed
        if [ -d $vroot$tmp ]; then
            mv $vroot$tmp $vroot$dest
    
    elijah's avatar
    elijah committed
        fi
    fi
    
    exit 0