[フレーム]
Last Updated: February 25, 2016
·
2.614K
· bousquet

Backup Remote SVN Repositories

We had an old svnserve instance with repositories that had mostly been abandoned since we switched to git. In preperation to shut things down, I wanted to backup those repositories locally in a way that would allow us to restore them in the rare instance it was needed. Here's a recipe that uses a combination of bash, svnsync and svnadmin to dump all revisions of each remote repository into svndump files on your local machine.

Step 1

Save the following script as svnbackup.sh:

#!/bin/sh
echo "Backing up repo: 1ドル"
svnadmin create 1ドル
echo "#!/bin/sh\nexit 0" >> `pwd`/1ドル/hooks/pre-revprop-change
chmod +x `pwd`/1ドル/hooks/pre-revprop-change
svnsync init file://`pwd`/1ドル svn://SOURCEURL/1ドル --source-username=USERNAME --source-password=PASSWORD
svnsync sync file://`pwd`/1ドル --source-username=USERNAME --source-password=PASSWORD
svnadmin dump 1ドル > 1ドル.svndump
echo "Cleaning up (1ドル)..."
rm -rf ./1ドル
echo "DONE"

Step 2

Make it executable:

$ chmod +x svnbackup.sh

You should now be able to run it on one repository by passing the repository name as the first argument:

$ svnbackup.sh repo1

Step 3

Setup a list of repositories to download in a file named svnrepos.txt, one repository per line:

repo1
repo2

Step 4

Use xargs to iterate over each repository in the fail, passing it into the backup script:

$ xargs -n1 < svnrepos.txt ./svnbackup.sh

Result

The result will be one <reponame>.svndump file for each repository in the list containing all revisions for that repository.

AltStyle によって変換されたページ (->オリジナル) /