You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by chobo2 <mh...@gmail.com> on 2008/10/31 00:26:16 UTC

How to backup all Repositories in a Directory?

Hi

I know there is svnadmin hotcopy is used to backup and I can make it backup
one repository. But I want to backup all repositories in that directory. How
would I go about doing this.

I am using windows xp.
-- 
View this message in context: http://www.nabble.com/How-to-backup-all-Repositories-in-a-Directory--tp20258114p20258114.html
Sent from the Subversion Users mailing list archive at Nabble.com.


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

Re: How to backup all Repositories in a Directory?

Posted by Thomas Harold <th...@nybeta.com>.
David Weintraub wrote:
> Here's my shell script that does just what you want. It backs up all
> repositories in your Subversion repository directory, puts on a
> timestamp, and then deletes all repository backups older than seven
> days.

Proof that there is more then one way to skin a cat.  Ours looks 
similar, but doesn't include a timestamp in the destination directory 
(we then use rdiff-backup to push the hotcopy folder to another location).

The downside is that you have to "rm -r" the destination folder every 
night, but the script takes care of that.  I ended up searching for the 
"db/uuid" file instead of "format".  And I'm not sure that the "db/uuid" 
file appears in BDB repository directories.

-----------------------------------
#!/bin/bash

BASE="/var/svn/"
HOTCOPY="/var/svn-hotcopy/"

FIND=/usr/bin/find
GREP=/bin/grep
RM=/bin/rm
SED=/bin/sed
SVNADMIN=/usr/bin/svnadmin

DIRS=`find ${BASE} -name uuid | $GREP 'db/uuid$' | $SED 's:/db/uuid$::' 
| $SED 's:^/var/svn/::'`

for DIR in ${DIRS}
do
     echo "svnadmin hotcopy ${BASE}${DIR} to ${HOTCOPY}${DIR}"

     if ! test -d ${HOTCOPY}${DIR}
     then
         mkdir -p ${HOTCOPY}${DIR}
     fi

     $RM -r ${HOTCOPY}${DIR}
     $SVNADMIN hotcopy ${BASE}${DIR} ${HOTCOPY}${DIR}
done

# insert rdiff-backup line here
-----------------------------------

I'll have to add in Marko's consistency check.

Marko's use of the find command is definitely slicker then using grep & 
sed, so I'll have to study that.

We used to setup the $DIRS folder manually by typing in all of the 
repository names by hand.  But we're getting read to break one of our 
monolithic repositories into about a dozen (or more) sub-repositories. 
Probably in sub-folders so that the SVN URLs don't change (which keeps 
us from breaking svn:externals).  So we needed something more robust 
that would search the entire /var/svn tree for any and all repositories, 
no matter how deeply nested.

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessageId=1015131

To unsubscribe from this discussion, e-mail: [users-unsubscribe@subversion.tigris.org].

Re: How to backup all Repositories in a Directory?

Posted by Marko Käning <mk...@mch.osram.de>.
Hi all,

by the way: it would be wise to introduce also a consistency check into 
David's script.

I attached my verify script as reference. (I picked it up some time ago 
here on the list and modified it only slightly.)

Quite handy to know that your backup copies are actually consistent.

Greets,
Marko

Re: How to backup all Repositories in a Directory?

Posted by David Weintraub <qa...@gmail.com>.
Here's my shell script that does just what you want. It backs up all
repositories in your Subversion repository directory, puts on a
timestamp, and then deletes all repository backups older than seven
days.

#! /bin/bash

########################################################################
# CONSTANTS
#
REPOS_BASE="/subversion/repositories"
BACKUP_DIR="/subversion/backups"
SVNADMIN_CMD="/usr/bin/svnadmin"
#
########################################################################

########################################################################
# BACKUP EACH AND EVERY REPOSITORY VIA THE "HOTCOPY" COMMAND
#
for repository in $REPOS_BASE/*
do
    reposBase=`basename $repository`
    date_string=`date "+%F"`
    backupName="$BACKUP_DIR/$date_string--$reposBase"
    [ -d "$backupName" ] && rm -rf $backupName/*
    mkdir -p "$backupName"
    "$SVNADMIN_CMD" hotcopy "$repository" "$backupName"
done
#
########################################################################

########################################################################
# DELETE BACKUPS OLDER THAN 7 DAYS OLD
#
find $BACKUP_DIR -mtime +7 -delete
#
########################################################################

--
David Weintraub
qazwart@gmail.com



On Thu, Oct 30, 2008 at 8:26 PM, chobo2 <mh...@gmail.com> wrote:
>
> Hi
>
> I know there is svnadmin hotcopy is used to backup and I can make it backup
> one repository. But I want to backup all repositories in that directory. How
> would I go about doing this.
>
> I am using windows xp.
> --
> View this message in context: http://www.nabble.com/How-to-backup-all-Repositories-in-a-Directory--tp20258114p20258114.html
> Sent from the Subversion Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
> For additional commands, e-mail: users-help@subversion.tigris.org
>
>

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

RE: How to backup all Repositories in a Directory?

Posted by John Niven <jn...@bravurasolutions.com>.
> -----Original Message-----
> From: chobo2 [mailto:mhubele@gmail.com]
> Sent: Friday, 31 October 2008 13:26
> To: users@subversion.tigris.org
> Subject: How to backup all Repositories in a Directory?
>
>
> Hi
>
> I know there is svnadmin hotcopy is used to backup and I can
> make it backup one repository. But I want to backup all
> repositories in that directory. How would I go about doing this.
>
> I am using windows xp.

You could run svnadmin hotcopy several times, or - better yet - write a script to do it for you?  Something like:

for each sub-directory (subdir) in present directory:
    svnadmin hotcopy $subdir backup\$subdir

Of course, you'd need to change the above pseudocode to your favourite scripting language.

Cheers
John

> --
> View this message in context:
> http://www.nabble.com/How-to-backup-all-Repositories-in-a-Dire
ctory--tp20258114p20258114.html
> Sent from the Subversion Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
> For additional commands, e-mail: users-help@subversion.tigris.org
>
>

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